当前位置: 首页>>代码示例>>PHP>>正文


PHP _strlen函数代码示例

本文整理汇总了PHP中_strlen函数的典型用法代码示例。如果您正苦于以下问题:PHP _strlen函数的具体用法?PHP _strlen怎么用?PHP _strlen使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了_strlen函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: reg

 public function reg()
 {
     if (isset($_POST['submit-1'])) {
         $username = safe_replace($_POST['username']);
         if ($username != $_POST['username'] || empty($username)) {
             _message("用户名格式错误!");
         }
         if (_strlen($username) > 15) {
             _message("用户名长度为2-15个字符,1个汉字等于2个字符!");
         }
         $password1 = $_POST['password'];
         $password2 = $_POST['pwdconfirm'];
         if (empty($password2) || $password1 != $password2) {
             _message("2次密码不一致!");
         }
         if (!_checkemail($_POST['email'])) {
             _message("邮箱格式错误!");
         }
         $pmid = isset($_POST['mid']) ? intval($_POST['mid']) : 0;
         $password = md5($password2);
         $addtime = time();
         $ip = _get_ip();
         $this->db->Query("INSERT INTO `@#_admin` (`mid`, `username`, `userpass`, `useremail`, `addtime`, `logintime`, `loginip`) VALUES ('{$pmid}', '{$username}', '{$password}', '{$_POST['email']}','{$addtime}','0','{$ip}')");
         if ($this->db->affected_rows()) {
             $path = WEB_PATH . '/' . ROUTE_M . '/user/lists';
             _message("添加管理员成功!", $path);
         } else {
             _message("添加管理员失败!");
         }
     }
     include $this->tpl(ROUTE_M, 'user.reg');
 }
开发者ID:haidao17,项目名称:backend,代码行数:32,代码来源:user.action.php

示例2: test_main

 public function test_main()
 {
     $str = 'Mutual Friends (пользователь должен быть у Вас в друзьях а Вы у него)';
     $this->assertEquals(111, strlen($str));
     $this->assertEquals(69, _strlen($str));
     $this->assertEquals(26, strlen(_substr($str, 0, 21)));
     $this->assertEquals(21, _strlen(_substr($str, 0, 21)));
 }
开发者ID:yfix,项目名称:yf,代码行数:8,代码来源:class_utf8.Test.php

示例3: strlen

 public static function strlen($str)
 {
     if (UTF8::$server_utf8) {
         return mb_strlen($str, JsonApiApplication::$charset);
     }
     if (!isset(UTF8::$called[__FUNCTION__])) {
         require JsonApiApplication::find_file("utf8", __FUNCTION__);
         // Function has been called
         UTF8::$called[__FUNCTION__] = TRUE;
     }
     return _strlen($str);
 }
开发者ID:benshez,项目名称:DreamWeddingCeremonies,代码行数:12,代码来源:UTF8.php

示例4: musername

 public function musername()
 {
     if (isset($_POST['ajax'])) {
         $usernamelen = 15;
         $pusername = isset($_POST['username']) ? $_POST['username'] : '';
         $len = _strlen($pusername);
         if ($len > $usernamelen || $len <= 0) {
             echo 'no';
         } else {
             echo 'yes';
         }
     }
 }
开发者ID:ping199143,项目名称:1ydb,代码行数:13,代码来源:checkform.action.php

示例5: autotranslate

 /**
  * Automatic translator via Google translate
  */
 function autotranslate()
 {
     if ($_POST['translate'] && $_POST['locale']) {
         set_time_limit(1800);
         $LOCALE_RES = $_POST['locale'];
         $base_url = 'http://ajax.googleapis.com/ajax/services/language/translate' . '?v=1.0';
         $vars = db()->query_fetch_all("SELECT id,value FROM " . db('locale_vars') . " WHERE id NOT IN( \n\t\t\t\t\tSELECT var_id FROM " . db('locale_translate') . " \n\t\t\t\t\tWHERE locale = '" . $LOCALE_RES . "' AND value != '' \n\t\t\t\t)");
         $_info = [];
         $max_threads = 4;
         $buffer = [];
         $translated = [];
         _debug_log("LOCALE_NUM_VARS: " . count($vars));
         foreach ((array) $vars as $A) {
             $translated = [];
             $url = $base_url . "&q=" . urlencode(str_replace("_", " ", $A["value"])) . "&langpair=en%7C" . $LOCALE_RES;
             $_temp[$url] = $A["id"];
             if (count($buffer) < $max_threads) {
                 $buffer[$url] = $url;
                 continue;
             }
             foreach ((array) common()->multi_request($buffer) as $url => $response) {
                 $response_array = json_decode($response);
                 $response_text = trim($response_array->responseData->translatedText);
                 $ID = $_temp[$url];
                 $source = str_replace("_", " ", $vars[$ID]["value"]);
                 _debug_log("LOCALE: " . ++$j . " ## " . $ID . " ## " . $source . " ## " . $response_text . " ## " . $url);
                 if (_strlen($response_text) && $response_text != $source) {
                     $translated[$ID] = $response_text;
                 }
             }
             if ($translated) {
                 $Q = db()->query("DELETE FROM " . db('locale_translate') . " \n\t\t\t\t\t\tWHERE locale = '" . _es($LOCALE_RES) . "' \n\t\t\t\t\t\t\tAND var_id IN(" . implode(",", array_keys($translated)) . ")");
             }
             foreach ((array) $translated as $_id => $_value) {
                 db()->REPLACE('locale_translate', ['var_id' => intval($_id), 'value' => _es($_value), 'locale' => _es($LOCALE_RES)]);
             }
             $buffer = [];
             $_temp = [];
         }
         cache_del('locale_translate_' . $LOCALE_RES);
         return js_redirect('./?object=' . $_GET['object']);
     }
     $Q = db()->query('SELECT * FROM ' . db('locale_langs') . ' ORDER BY name');
     while ($A = db()->fetch_assoc($Q)) {
         $locales[$A['locale']] = $A['name'];
     }
     $replace = ['locale_box' => common()->select_box('locale', $locales), 'locale_editor_url' => './?object=locale_editor', 'form_action' => './?object=' . $_GET['object'] . '&action=' . $_GET['action']];
     return tpl()->parse($_GET['object'] . '/autotranslate', $replace);
 }
开发者ID:yfix,项目名称:yf,代码行数:52,代码来源:yf_locale_editor_autotranslate.class.php

示例6: reg

 public function reg()
 {
     function randomkeys($length)
     {
         $pattern = '1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLOMNOPQRSTUVWXYZ';
         for ($i = 0; $i < $length; $i++) {
             $key .= $pattern[mt_rand(0, 35)];
             //生成php随机数
         }
         return $key;
     }
     if (isset($_POST['submit-1'])) {
         $username = safe_replace($_POST['username']);
         if ($username != $_POST['username'] || empty($username)) {
             _message("用户名格式错误!");
         }
         if (_strlen($username) > 15) {
             _message("用户名长度为2-15个字符,1个汉字等于2个字符!");
         }
         $password1 = $_POST['password'];
         $password2 = $_POST['pwdconfirm'];
         if (empty($password2) || $password1 != $password2) {
             _message("2次密码不一致!");
         }
         if (!_checkemail($_POST['email'])) {
             _message("邮箱格式错误!");
         }
         $pmid = isset($_POST['mid']) ? intval($_POST['mid']) : 0;
         $password = md5($password2);
         $uid = $password;
         $addtime = time();
         $ip = _get_ip();
         $this->db->Query("INSERT INTO `@#_admin` (`uid`, `mid`, `username`, `userpass`, `useremail`, `addtime`, `logintime`, `loginip`) VALUES ('{$uid}', '{$pmid}', '{$username}', '{$password}', '{$_POST['email']}','{$addtime}','0','{$ip}')");
         if ($this->db->affected_rows()) {
             $path = WEB_PATH . ROUTE_M . '/user/lists';
             _message("添加管理员成功!", $path);
         } else {
             _message("添加管理员失败!");
         }
     }
     include $this->tpl(ROUTE_M, 'user.reg');
 }
开发者ID:ping199143,项目名称:1ydb,代码行数:42,代码来源:user.action.php

示例7: strlen

 /**
  * Returns the length of the given string.
  * @see http://php.net/strlen
  *
  * @param   string   string being measured for length
  * @return  integer
  */
 public static function strlen($str)
 {
     require_once dirname(__FILE__) . '/' . __FUNCTION__ . '.php';
     return _strlen($str);
 }
开发者ID:abhinay100,项目名称:forma_app,代码行数:12,代码来源:lib.utf8.php

示例8: password_verify

 /**
  * Verify a password against a hash using a timing attack resistant approach
  *
  * @param string $password The password to verify
  * @param string $hash The hash to verify against
  *
  * @return boolean If the password matches the hash
  */
 function password_verify($password, $hash)
 {
     if (!function_exists('crypt')) {
         trigger_error("Crypt must be loaded for password_verify to function", E_USER_WARNING);
         return false;
     }
     $ret = crypt($password, $hash);
     if (!is_string($ret) || _strlen($ret) != _strlen($hash) || _strlen($ret) <= 13) {
         return false;
     }
     $status = 0;
     for ($i = 0; $i < _strlen($ret); $i++) {
         $status |= ord($ret[$i]) ^ ord($hash[$i]);
     }
     return $status === 0;
 }
开发者ID:jetfirephp,项目名称:framework,代码行数:24,代码来源:system.php

示例9: strlen

 /**
  * Returns the length of the given string. This is a UTF8-aware version
  * of [strlen](http://php.net/strlen).
  *
  *     $length = UTF8::strlen($str);
  *
  * @param   string  $str    string being measured for length
  * @return  integer
  * @uses    UTF8::$server_utf8
  * @uses    Kohana::$charset
  */
 public static function strlen($str)
 {
     if (UTF8::$server_utf8) {
         return mb_strlen($str, Kohana::$charset);
     }
     if (!isset(UTF8::$called[__FUNCTION__])) {
         require Kohana::find_file('utf8', __FUNCTION__);
         // Function has been called
         UTF8::$called[__FUNCTION__] = TRUE;
     }
     return _strlen($str);
 }
开发者ID:Chinese1904,项目名称:openclassifieds2,代码行数:23,代码来源:UTF8.php

示例10: strlen

 /**
  * Returns the length of the given string. This is a UTF8-aware version
  * of [strlen](http://php.net/strlen).
  *
  *     $length = UTF8::strlen($str);
  *
  * @param   string  $str    string being measured for length
  * @return  integer
  * @uses    UTF8::$server_utf8
  * @uses    Phalcana\Phalcana::$charset
  */
 public static function strlen($str)
 {
     if (UTF8::$server_utf8) {
         return mb_strlen($str, Phalcana::$charset);
     }
     if (!isset(UTF8::$called[__FUNCTION__])) {
         require Phalcana::$di->get('fs')->findFile('utf8', __FUNCTION__);
         // Function has been called
         UTF8::$called[__FUNCTION__] = true;
     }
     return _strlen($str);
 }
开发者ID:braf,项目名称:phalcana-core,代码行数:23,代码来源:UTF8.php

示例11: strlen

 /**
  * Returns the length of the given string. This is a UTF8-aware version
  * of [strlen](http://php.net/strlen).
  *
  *     $length = UTF8::strlen($str);
  *
  * @param   string  $str    string being measured for length
  * @return  integer
  * @uses    UTF8::$server_utf8
  * @uses    Kohana::$charset
  */
 public static function strlen($str)
 {
     if (UTF8::$server_utf8) {
         return mb_strlen($str, 'utf-8');
     }
     return _strlen($str);
 }
开发者ID:doorframework,项目名称:core,代码行数:18,代码来源:UTF8.php

示例12: chart_flash

 /**
  */
 function chart_flash($data, $params)
 {
     if (empty($data)) {
         return;
     }
     include_once YF_PATH . 'libs/yf_open_flash_chart/open-flash-chart.php';
     $width = isset($params['width']) ? $params['width'] : '90%';
     $height = isset($params['height']) ? $params['height'] : '90%';
     $g = new graph();
     $g->js_path = isset($params['js_path']) ? $params['js_path'] : '/js/';
     $g->swf_path = isset($params['swf_path']) ? $params['swf_path'] : '/js/';
     $g->title(' ', '{font-size: 20px;}');
     $g->bg_colour = '#e9e9e9';
     $g->x_axis_colour('#000000', '#c1c1c1');
     $g->y_axis_colour('#000000', '#c1c1c1');
     $g->set_data($data);
     // Find maximal strlen of x axis label
     foreach ((array) $data as $k => $v) {
         $xlabel_len[] = _strlen($k);
     }
     if (max($xlabel_len) > 7) {
         $orientation = 2;
     } else {
         $orientation = 0;
     }
     $g->set_x_labels(array_keys($data));
     $g->set_x_label_style(10, '#000000', $orientation, 2);
     $g->set_y_max(max($data));
     $g->set_y_label_style(10, '#000000', 0, 2);
     $g->set_y_legend('Price', 10, '#000000');
     $g->set_x_legend('Date', 10, '#000000');
     $g->set_tool_tip('#val# EUR on #x_label#');
     $g->line_dot(2, 3, '#0750D9', '', 10);
     // формат значений
     $g->set_num_decimals(0);
     $g->set_y_format('#val#&euro;');
     $g->set_width($width);
     $g->set_height($height);
     $g->set_output_type('js');
     return $g->render();
 }
开发者ID:yfix,项目名称:yf,代码行数:43,代码来源:yf_charts.class.php

示例13: _get_keywords_from_text

 /**
  * Analyze text, find top keywords and return string ready for use inside 'MATCH ... AGAINST ...'
  */
 function _get_keywords_from_text($text = '')
 {
     $num_to_ret = $this->NUM_KEYWORDS;
     $wordlist = preg_split($this->_PATTERN_KWORDS, _strtolower(strip_tags($text)));
     // Build an array of the unique words and number of times they occur.
     $a = array_count_values($wordlist);
     // Remove the stop words from the list.
     foreach ((array) $this->STOP_WORDS as $_word) {
         unset($a[$_word]);
     }
     // Remove short words from the list.
     foreach ((array) $a as $k => $v) {
         if (_strlen($k) < 4) {
             unset($a[$k]);
         }
     }
     arsort($a, SORT_NUMERIC);
     $num_words = count($a);
     $num_to_ret = $num_words > $this->num_to_ret ? $num_to_ret : $num_words;
     $outwords = array_slice($a, 0, $num_to_ret);
     $result = implode(' ', array_keys($outwords));
     return $result;
 }
开发者ID:yfix,项目名称:yf,代码行数:26,代码来源:yf_related_content.class.php

示例14: getTextBetweenTags

function getTextBetweenTags($text, $tag)
{
    $StartTag = "<{$tag}";
    $EndTag = "</{$tag}";
    $StartPosTemp = _strpos($text, $StartTag);
    $StartPos = _strpos($text, '>', $StartPosTemp);
    $StartPos = $StartPos + 1;
    $EndPos = _strpos($text, $EndTag);
    $StartAttr = $StartPosTemp + _strlen($StartTag) + 1;
    $EndAttr = $StartPos;
    if ($EndAttr > $StartAttr) {
        $attribute = _substr($text, $StartAttr, $EndAttr - $StartAttr - 1);
        $datas = explode(' ', $attribute);
        for ($i = 0; $i < sizeof($datas); $i++) {
            if (preg_match('/^([a-zA-Z:]+)=["\'](.*)["\']/', $datas[$i], $match)) {
                $items[$match[1]] = $match[2];
            }
        }
    }
    $text = _substr($text, $StartPos, $EndPos - $StartPos);
    if (_strpos($text, '[CDATA[') == false) {
        $text = str_replace('&lt;', '<', $text);
        $text = str_replace('&gt;', '>', $text);
        $text = str_replace('&amp;', '&', $text);
        $text = str_replace('&quot;', '"', $text);
    } else {
        $text = str_replace('<![CDATA[', '', $text);
        $text = str_replace(']]>', '', $text);
    }
    $items['data'] = trim($text);
    return $items;
}
开发者ID:phannack,项目名称:GCMS,代码行数:32,代码来源:reader.php

示例15: strlen

 /**
  * Returns the length of the given string. This is a UTF8-aware version
  * of [strlen](http://php.net/strlen).
  *
  *     $length = UTF8::strlen($str);
  *
  * @param   string   string being measured for length
  * @return  integer
  * @uses    UTF8::$server_utf8
  */
 public static function strlen($str)
 {
     if (UTF8::$server_utf8) {
         return mb_strlen($str, Kohana::$charset);
     }
     if (!isset(self::$called[__FUNCTION__])) {
         require SYSPATH . 'utf8' . DIRECTORY_SEPARATOR . __FUNCTION__ . EXT;
         // Function has been called
         self::$called[__FUNCTION__] = TRUE;
     }
     return _strlen($str);
 }
开发者ID:gilyaev,项目名称:framework-bench,代码行数:22,代码来源:utf8.php


注:本文中的_strlen函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。