本文整理汇总了PHP中str_len函数的典型用法代码示例。如果您正苦于以下问题:PHP str_len函数的具体用法?PHP str_len怎么用?PHP str_len使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了str_len函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fix_avatars
public function fix_avatars()
{
connect();
$array = mysql_array("SELECT distinct md5(email), email from jq_comments");
foreach ($array as $row) {
$email = $row[1];
$data = file_get_contents('http://www.gravatar.com/avatar/' . $row[0] . '.png?d=404&s=48');
if ($data) {
$avatar = "avatars/" . $row[0] . ".png";
$file = fopen($avatar, "w");
if (!$file) {
throw new Exception("IO Error: Can't open file {$avatar}");
}
fwrite($avatar, $data);
fclose($file);
} else {
$avatar = "avatars/default.png";
}
$avatars[] = array($avatar, str_len($data));
if (!mysql_query("UPDATE jq_comments set avatar = '{$avatar}' where email = '{$email}'")) {
throw new Exception("Can't update {$row[1]}");
}
}
return $avatars;
}
示例2: checkCreatedOn
/**
* @author: 肖红阳
* check created_on column
* @param $attribute
*/
public function checkCreatedOn($attribute, $params)
{
p($this->{$attribute});
if (empty($this->{$attribute}) || str_len($this->{$attribute}) < 4 || is_null($this->{$attribute}) || !$this->{$attribute} > 0) {
$this->addError($attribute, "created_on 错误!");
} else {
$this->setAttribute($attribute, $this->{$attribute});
}
}
示例3: get_ip
function get_ip()
{
$ip = "UNBEKANNT";
if (isset($_SERVER['HTTP_CLIENT_IP']) && str_len($_SERVER['HTTP_CLIENT_IP'])) {
$ip = $_SERVER["HTTP_CLIENT_IP"];
} else {
if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && str_len($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip = $_SERVER["HTTP_X_FORWARDED_FOR"];
} else {
if ($_SERVER["REMOTE_ADDR"]) {
$ip = $_SERVER["REMOTE_ADDR"];
}
}
}
return $ip;
}
示例4: get_order_info
function get_order_info()
{
$datetime = $_GET['datetime'];
$order_sn = trim($_GET['order_sn']);
$print_sn = trim($_GET['print_sn']);
$where = "where i.country " . $GLOBALS['city_code'];
if ($datetime) {
$where .= " and l.bdate='" . $datetime . "'";
}
if ($print_sn) {
$where .= " and l.print_sn='" . $print_sn . "'";
}
if ($order_sn) {
if (str_len($order_sn) == 5) {
$where .= " and i.order_sn like '%{$order_sn}'";
} else {
$where = "where i.country " . $GLOBALS['city_code'] . " and i.order_sn='" . $order_sn . "'";
}
}
$sql = "SELECT i.order_sn,i.inv_payee,i.inv_content,i.postscript,i.money_address,i.scts,i.wsts,i.card_message,i.order_id, i.order_status, i.pay_status, i.orderman, i.consignee, i.add_time as time1, i.pay_name, i.best_time, i.province, i.address, g.remark, dis.status as sta1, dis.route_id, dis.turn, dis.add_time as time2, l.ptime, l.stime, l.print_sn,l.bdate, del.status as sta2, rou.route_code, s.station_name\r\n\tFROM ecs_order_info AS i\r\n\tLEFT JOIN order_genid AS g ON g.order_id = i.order_id\r\n\tLEFT JOIN order_dispatch AS dis ON dis.order_id = i.order_id\r\n\tLEFT JOIN print_log_x AS l ON l.order_id = dis.order_id \r\n\tLEFT JOIN order_delivery AS del ON del.order_id = i.order_id\r\n\tLEFT JOIN ship_route AS rou ON rou.route_id = dis.route_id\r\n\tLEFT JOIN ship_station AS s ON rou.station_id = s.station_id " . $where . " limit 1";
$arr = $GLOBALS['db_read']->getRow($sql);
if ($arr['order_id']) {
$sql = "select goods_name,goods_attr,goods_number from ecs_order_goods as goo where order_id='" . $arr['order_id'] . "' and goods_attr!=''";
$arr2 = $GLOBALS['db_read']->getAll($sql);
} else {
$arr2 = array();
}
foreach ($arr2 as $k => $v) {
$arr2[$k]['goods_name'] = $v['goods_name'] . "--" . $v['goods_attr'] . "--" . $v['goods_number'];
if ($k != 0) {
$arr2[0]['goods_name'] .= " | " . $arr2[$k]['goods_name'];
}
}
$sql = "select sum(goods_number) as c_num from ecs_order_goods as goo where order_id='" . $arr['order_id'] . "' and goods_id='60'";
$c_arr = $GLOBALS['db_read']->getOne($sql);
$sql = "select sum(goods_number) as l_num from ecs_order_goods as goo where order_id='" . $arr['order_id'] . "' and goods_id='61'";
$l_arr = $GLOBALS['db_read']->getOne($sql);
return array("order_info" => $arr, "goods_info" => $arr2, "cj" => $c_arr, "lz" => $l_arr);
}
示例5: get_order_info
function get_order_info()
{
$datetime = empty($_GET['datetime']) ? date("Y-m-d") : $_GET['datetime'];
$order_sn = empty($_GET['order_sn']) ? "" : trim($_GET['order_sn']);
$print_sn = empty($_GET['print_sn']) ? "" : trim($_GET['print_sn']);
$where = "where i.country " . $GLOBALS['city_code'];
if ($datetime) {
$where .= " and l.bdate='" . $datetime . "'";
}
if ($print_sn) {
$where .= " and l.print_sn='" . $print_sn . "' ";
}
if ($order_sn) {
if (str_len($order_sn) == 5) {
$where .= " and i.order_sn like '%{$order_sn}' ";
} else {
$where = "where i.order_sn='" . $order_sn . "'";
}
}
$sql = "SELECT i.order_sn,i.order_id, i.best_time, l.ptime, l.stime, l.print_sn,bdate \r\n\tFROM ecs_order_info AS i\r\n\tLEFT JOIN order_genid AS g ON g.order_id = i.order_id\r\n\tLEFT JOIN order_dispatch AS dis ON dis.order_id = i.order_id\r\n\tLEFT JOIN print_log_x AS l ON l.order_id = dis.order_id \r\n\tLEFT JOIN order_delivery AS del ON del.order_id = i.order_id\r\n\tLEFT JOIN ship_route AS rou ON rou.route_id = dis.route_id\r\n\tLEFT JOIN ship_station AS s ON rou.station_id = s.station_id " . $where . " limit 1";
$arr = $GLOBALS['db_read']->getRow($sql);
return $arr;
}
示例6: empty
exit;
case 'register':
//更新数据库数据
$sms_server_id = empty($_POST["sms_server_id"]) ? 0 : intval($_POST["sms_server_id"]);
$user = trim($_POST["user"]);
$pass = trim($_POST["pass"]);
$server = trim($_POST["server"]);
$port = trim($_POST["port"]);
$total = empty($_POST["total"]) ? 0 : intval($_POST["total"]);
$is_active = empty($_POST["is_active"]) ? 0 : intval($_POST["is_active"]);
$phone = trim($_POST["phone"]);
$sql = "update " . $ecs->table("sms_server") . " set user='{$user}',pass='{$pass}',server='{$server}',port='{$port}',is_active='{$is_active}',total='{$total}' where sms_server_id=" . $sms_server_id;
$db->query($sql);
$msg = "服务器设置成功!";
//短信测试
if ($is_active && str_len($phone) > 3) {
$sms = new sms();
$res = $sms->send($phone, "您好,您已开通您的短信服务,感谢您的使用!【磐盛科技】", "", "", $_SESSION["admin_name"]);
if ($res['error'] == 1) {
$msg .= $res['msg'];
} else {
$msg .= "请查收短信";
}
}
sys_msg($msg, 0, array(), false);
exit;
case 'sense':
$smarty->assign('ur_here', "敏感词汇");
$sms = new sms();
$smarty->assign('sense', implode("|", $sms->sense));
assign_query_info();
示例7: create_menu
public function create_menu($db)
{
$this->access_token($db);
$ret = $db->getRow("SELECT `access_token` FROM `wxch_config`");
$access_token = $ret['access_token'];
if (strlen($access_token) == 150) {
$url = 'https://api.weixin.qq.com/cgi-bin/menu/create?access_token=' . $access_token;
$menu = '{
"button":[
{
"type":"click",
"name":"新款推荐",
"key":"XKTJ"
},
{
"type":"click",
"name":"绑定会员",
"key":"BDHY"
},
{
"name":"帮助",
"sub_button":[
{
"type":"click",
"name":"订单查询",
"key":"DDCX",
},
{
"type":"click",
"name":"快递查询",
"key":"KDCX",
},
{
"type":"click",
"name":"帮助",
"key":"HELP"
}]
}]
}';
$ret = $this->curl_grab_page($url, $menu);
$errmsg = $ret->errmsg;
if ($errmsg == 'ok') {
echo '创建菜单成功';
} else {
$i = 1;
$max = 100;
for ($i; $i <= $max; $i++) {
sleep(1);
$ret_json = $this->curl_grab_page($url, $menu);
$ret = json_decode($ret_json);
if ($ret->errcode == 0) {
echo '尝试第' . $i . '时成功创建';
break;
}
}
if ($ret->errcode == -1) {
echo '尝试创建' . $i . '次菜单失败,请稍后再试';
}
}
print_r($ret);
} else {
echo 'access_token:' . str_len($access_token);
}
}
示例8: linktipp_display
function linktipp_display($linktipp, $addclass = '')
{
global $options;
if (!isset($linktipp)) {
return;
}
$post_id = isset($linktipp->ID) ? $linktipp->ID : 0;
$title = get_the_title($linktipp);
$linktipp_url = get_post_meta($post_id, 'linktipp_url', true);
$linktipp_imgid = get_post_meta($post_id, 'linktipp_imgid', true);
$linktipp_image = get_post_meta($post_id, 'linktipp_image', true);
$linktipp_untertitel = get_post_meta($post_id, 'linktipp_untertitel', true);
$linktipp_text = get_post_meta($post_id, 'linktipp_text', true);
if (isset($linktipp_untertitel) && !isset($title)) {
$title = $linktipp_untertitel;
$linktipp_untertitel = '';
}
$out = '';
$out .= '<section class="p3-column linktipps ' . $addclass . '" id="post-' . $post_id . '" >';
$out .= "\n";
if ($options['linktipps-titlepos'] != 1) {
$out .= '<header class="post-title p3-cbox">';
if (mb_strlen(trim($linktipp_untertitel)) > 1) {
$out .= '<div class="hgroup">';
}
if ($options['linktipps-subtitlepos'] == 0 && mb_strlen(trim($linktipp_untertitel)) > 1) {
$out .= '<h3 class="subtitle">' . $linktipp_untertitel . '</h3>';
}
$out .= '<h2>';
if ($options['linktipps-linkpos'] == 0 || $options['linktipps-linkpos'] == 3) {
$out .= '<a href="' . $linktipp_url . '" rel="bookmark">';
}
$out .= $title;
if ($options['linktipps-linkpos'] == 0 || $options['linktipps-linkpos'] == 3) {
$out .= '</a>';
}
$out .= '</h2>';
if ($options['linktipps-subtitlepos'] == 1 && mb_strlen(trim($linktipp_untertitel)) > 1) {
$out .= '<h3 class="subtitle">' . $linktipp_untertitel . '</h3>';
}
if (mb_strlen(trim($linktipp_untertitel)) > 1) {
$out .= '</div>';
}
$out .= '</header>';
$out .= "\n";
}
$out .= '<div class="p3-column">';
$out .= "\n";
$out .= '<article class="post-entry p3-cbox">';
$out .= "\n";
if ($options['linktipps-linkpos'] == 1) {
$out .= '<a href="' . $linktipp_url . '">';
}
if (isset($linktipp_imgid) && $linktipp_imgid > 0) {
$image_attributes = wp_get_attachment_image_src($linktipp_imgid, 'linktipp-thumb');
if (is_array($image_attributes)) {
$out .= '<img src="' . $image_attributes[0] . '" width="' . $image_attributes[1] . '" height="' . $image_attributes[2] . '" alt="' . trim(strip_tags($linktipp_text)) . '">';
}
} elseif (isset($linktipp_image)) {
$out .= '<img src="' . $linktipp_image . '" alt="">';
}
if ($options['linktipps-linkpos'] == 1) {
$out .= '</a>';
}
if (isset($linktipp_text)) {
$out .= piratenkleider_make_nice_links($linktipp_text);
}
$out .= "</article>\n";
if ($options['linktipps-titlepos'] == 1) {
$out .= '<header class="post-title p3-cbox">';
if (str_len(trim($linktipp_untertitel)) > 1) {
$out .= '<div class="hgroup">';
}
if ($options['linktipps-subtitlepos'] == 0 && str_len(trim($linktipp_untertitel)) > 1) {
$out .= '<h3 class="subtitle">' . $linktipp_untertitel . '</h3>';
}
$out .= '<h2>';
if ($options['linktipps-linkpos'] == 0 || $options['linktipps-linkpos'] == 3) {
$out .= '<a href="' . $linktipp_url . '" rel="bookmark">';
}
$out .= $title;
if ($options['linktipps-linkpos'] == 0 || $options['linktipps-linkpos'] == 3) {
$out .= '</a>';
}
$out .= '</h2>';
if ($options['linktipps-subtitlepos'] == 1 && str_len(trim($linktipp_untertitel)) > 1) {
$out .= '<h3 class="subtitle">' . $linktipp_untertitel . '</h3>';
}
if (str_len(trim($linktipp_untertitel)) > 1) {
$out .= '</div>';
}
$out .= '</header>';
$out .= "\n";
}
if ($options['linktipps-linkpos'] == 2 || $options['linktipps-linkpos'] == 3) {
$out .= '<footer class="linktipp-url"><a class="extern" href="' . $linktipp_url . '">' . $linktipp_url . '</a></footer>';
}
$out .= "</div>\n";
$out .= "</section>\n";
return $out;
//.........这里部分代码省略.........
示例9: search_smart_truncate
function search_smart_truncate($text, $len, $needles)
{
if (is_array($needles) && count($needles)) {
return truncatePreserveWords($text, $needles);
} else {
if (str_len($txt) > $len) {
return word_limiter($text, $len);
}
}
}
示例10: str_len
<?php
$firstName = 'Andy';
$nameLength = str_len($firstName);
$myVar = 'Hi, my name is ' . $nameLength . ' letters long.';
echo $myVar;
示例11: create_menu
public function create_menu($db)
{
$this->access_token($db);
$ret = $db->getRow("SELECT `access_token` FROM `wxch_config`");
$access_token = $ret['access_token'];
if (strlen($access_token) == 150) {
$url = 'https://api.weixin.qq.com/cgi-bin/menu/create?access_token=' . $access_token;
// $arr = array(
// 'button' => array(
// array('type'=>'click','name'=>'新款推荐','key'=>'XKTJ'),
// array('type'=>'click','name'=>'绑定会员','key'=>'BDHY'),
// array('name'=>'更多','sub_button'=>array(
// array('type'=>'click','name'=>'订单查询','key'=>'DDCX'),
// array('type'=>'click','name'=>'快递查询','key'=>'KDCX'),
// array('type'=>'click','name'=>'帮助','key'=>'HELP')
// )
// )
// )
// );
// $arr = mb_convert_encoding($arr, "GBK", "UTF-8");
// print_r($arr);exit;
// $menu = json_encode($arr);
// print_r($menu);exit;
//
$menu = '{
"button":[
{
"type":"click",
"name":"新款推荐",
"key":"XKTJ"
},
{
"type":"click",
"name":"绑定会员",
"key":"BDHY"
},
{
"name":"帮助",
"sub_button":[
{
"type":"click",
"name":"订单查询",
"key":"DDCX",
},
{
"type":"click",
"name":"快递查询",
"key":"KDCX",
},
{
"type":"click",
"name":"帮助",
"key":"HELP"
}]
}]
}';
// print_r($menu);exit;
// $menu = mb_convert_encoding($menu, "UTF-8", "GBK");
// $menu_arr = json_decode($menu,TRUE);
$ret = $this->curl_grab_page($url, $menu);
$errmsg = $ret->errmsg;
if ($errmsg == 'ok') {
echo '创建菜单成功';
} else {
$i = 1;
$max = 100;
for ($i; $i <= $max; $i++) {
sleep(1);
$ret_json = $this->curl_grab_page($url, $menu);
$ret = json_decode($ret_json);
if ($ret->errcode == 0) {
echo '尝试第' . $i . '时成功创建';
break;
}
}
if ($ret->errcode == -1) {
echo '尝试创建' . $i . '次菜单失败,请稍后再试';
}
}
print_r($ret);
} else {
echo 'access_token:' . str_len($access_token);
}
}
示例12: order_list
function order_list()
{
$filter['sdate'] = empty($_REQUEST['sdate']) ? '' : trim($_REQUEST['sdate']);
$filter['order_sn'] = empty($_REQUEST['order_sn']) ? '' : trim($_REQUEST['order_sn']);
$filter['turn'] = empty($_REQUEST['turn']) ? 0 : intval($_REQUEST['turn']);
$filter['station'] = empty($_REQUEST['station']) ? '' : intval($_REQUEST['station']);
$filter['employee'] = empty($_REQUEST['employee']) ? '' : intval($_REQUEST['employee']);
$filter['pack_no'] = empty($_REQUEST['pack_no']) ? '' : trim($_REQUEST['pack_no']);
$filter['print_sn'] = empty($_REQUEST['print_sn']) ? '' : trim($_REQUEST['print_sn']);
$filter['status'] = empty($_REQUEST['status']) ? '' : intval($_REQUEST['status']);
$filter['orderstatus'] = empty($_REQUEST['orderstatus']) ? '' : intval($_REQUEST['orderstatus']);
$filter['page'] = empty($_REQUEST['page']) || intval($_REQUEST['page']) <= 0 ? 1 : intval($_REQUEST['page']);
$where = " where o.country " . $GLOBALS['city_code'] . " ";
if ($filter['sdate']) {
$where .= " and best_time > '" . $filter['sdate'] . "' and best_time < '" . $filter['sdate'] . " 23:30:00'";
}
if ($filter['turn']) {
$where .= " and c.turn = '" . $filter['turn'] . "' ";
}
if ($filter['employee']) {
$where .= " and employee_id = '" . $filter['employee'] . "' ";
}
if ($filter['pack_no']) {
$where .= " and d.route_name = '" . $filter['pack_no'] . "' ";
}
if ($filter['status']) {
$where .= " and a.status = '" . $filter['status'] . "' ";
}
if ($filter['orderstatus'] == 0) {
$where .= " and order_status =0 ";
}
if ($filter['orderstatus'] == 1) {
$where .= " and order_status =1 ";
}
if ($filter['orderstatus'] == 2) {
$where .= " and order_status =2 ";
}
if ($filter['orderstatus'] == 3) {
$where .= " and order_status =3 ";
}
if ($filter['orderstatus'] == 4) {
$where .= " and order_status =4 ";
}
if ($filter['order_sn']) {
if (str_len($filter['order_sn']) == 5) {
$where .= " and order_sn like '%" . $filter['order_sn'] . "' ";
} else {
$where = " where order_sn = '" . $filter['order_sn'] . "' ";
}
}
if ($filter['station'] && $filter['station'] != 100) {
$where .= " and d.station_id = '" . $filter['station'] . "' ";
}
if ($filter['print_sn']) {
$where .= "and p.print_sn = '" . $filter['print_sn'] . "' ";
}
if ($filter['station'] == 100) {
$where .= " and shipping_station_name is null ";
}
if ($filter['sort_by'] == 'shipping_station_name') {
$orderby = "shipping_pack_no,best_time ";
} elseif ($filter['sort_by'] == 'shipping_pack_no') {
$orderby = "shipping_station_name, best_time ";
} else {
$orderby = "shipping_station_name, shipping_pack_no ";
}
if ($_SESSION['station'] > 0) {
$where .= " and d.station_id = '" . $_SESSION['station'] . "' ";
}
$size = 30;
$sql = "select count(1) " . "from order_delivery as a " . "left join ecs_order_info as o on a.order_id=o.order_id " . "left join order_dispatch as c on a.order_id=c.order_id " . "left join print_log_x as p on a.order_id=p.order_id " . "left join hr_employees as h on a.employee_id=h.id " . "left join ship_route as d on c.route_id=d.route_id " . "left join ship_station as s on d.station_id=s.station_id " . $where;
$record_count = $GLOBALS['db_read']->getOne($sql);
$page_count = $record_count > 0 ? ceil($record_count / $size) : 1;
$sql = "select a.order_id,p.print_sn,o.order_sn,o.city,o.address,o.best_time,c.*,d.*,s.station_name,s.station_code,a.status,h.name as employee_name " . "from order_delivery as a " . "left join ecs_order_info as o on a.order_id=o.order_id " . "left join order_dispatch as c on a.order_id=c.order_id " . "left join print_log_x as p on a.order_id=p.order_id " . "left join hr_employees as h on a.employee_id=h.id " . "left join ship_route as d on c.route_id=d.route_id " . "left join ship_station as s on d.station_id=s.station_id " . $where . "order by d.route_name,c.turn,best_time " . "LIMIT " . ($filter['page'] - 1) * $size . ",{$size}";
$res = $GLOBALS['db_read']->GetAll($sql);
$sql = "SELECT a.sender,b.name FROM delivery_plan as a,hr_employees as b WHERE a.sender=b.id and bdate = '" . $filter['sdate'] . "' \r\n\t\t\tand a.station_id = '" . $filter['station'] . "'";
$res2 = $GLOBALS['db_read']->GetAll($sql);
foreach ($res as $key => $val) {
$res[$key]['i'] = $key + 1;
$res[$key]['address'] = region_name($val['city']) . ' ' . $val['address'];
}
$arr = array('orders' => $res, 'filter' => $filter, 'page_count' => $page_count, 'record_count' => $record_count, 'senders' => $res2);
return $arr;
}
示例13: createLicense
function createLicense($max_id, $sum)
{
$yard = yard();
$license = array();
for ($i = 0; $i < $sum; $i++) {
$time = time() + ++$max_id;
//时间戳加上当前最大的id号表示唯一
$li = dechex($time);
//将唯一编号转换为十六进制
$total = 0;
for ($j = 0; $j < str_len($li); $j++) {
$res = ord($li[$j]);
//计算这些十六进制asic码总和
$total += $res;
}
$total = $total % 36;
//将total模上36,获取最后一位校验码
$y = $yard[$total];
$li = $li . "" . $y;
$license[] = $li;
// echo $li.'<br><br>';
}
return $license;
}
示例14: convert_back_cbs
function convert_back_cbs($cb_val)
{
$cb_str = (string) $cb_val;
$len = str_len($cb_arr);
while ($len <= 5) {
$cb_str .= '0';
$len++;
}
return str_split($cb_str);
}
示例15: max_length
/**
* Max Length
*
* @access public
* @param string
* @param value
* @return bool
*/
public function max_length($str, $val)
{
if (preg_match("/[^0-9]/", $val)) {
return FALSE;
}
//if (function_exists('mb_strlen'))
//{
// return (mb_strlen($str) > $val) ? FALSE : TRUE;
//}
return str_len($str) > $val ? FALSE : TRUE;
}