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


PHP utf8_strlen函数代码示例

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


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

示例1: _preSave

 protected function _preSave()
 {
     $team = $this->_getTeamData();
     if (!$team) {
         $this->error(new XenForo_Phrase('requested_team_not_found'), 'team_id');
     }
     if ($team['user_id'] == $this->get('user_id')) {
         throw new Nobita_Teams_Exception_Abstract("You can't give banning to Owner of Team.", true);
         return false;
     }
     if ($this->isChanged('user_id')) {
         $userBan = $this->_getBanningModel()->getBanningByKeys($team['team_id'], $this->get('user_id'));
         if ($userBan) {
             $this->error(new XenForo_Phrase('this_user_is_already_banned'), 'user_id');
         } else {
             $user = $this->getModelFromCache('XenForo_Model_User')->getUserById($this->get('user_id'));
             if (!$user || $user['is_moderator'] || $user['is_admin']) {
                 $this->error(new XenForo_Phrase('this_user_is_an_admin_or_moderator_choose_another'), 'user_id');
             }
         }
     }
     $reason = trim($this->get('user_reason'));
     if (!utf8_strlen($reason)) {
         $this->error(new XenForo_Phrase('Teams_please_enter_reason_for_ban_user'), 'user_reason');
     } elseif (utf8_strlen($reason) > 255) {
         $this->error(new XenForo_Phrase('please_enter_message_with_no_more_than_x_characters', array('count' => 255)), 'user_reason');
     }
     if (!$this->get('end_date')) {
         throw new Nobita_Teams_Exception_Abstract("Please provide the end date.", true);
     }
 }
开发者ID:Sywooch,项目名称:forums,代码行数:31,代码来源:Banning.php

示例2: utf8_str_pad

/**
* Replacement for str_pad. $padStr may contain multi-byte characters.
*
* @author Oliver Saunders <oliver (a) osinternetservices.com>
* @param string $input
* @param int $length
* @param string $padStr
* @param int $type ( same constants as str_pad )
* @return string
* @see http://www.php.net/str_pad
* @see utf8_substr
* @package utf8
* @subpackage strings
*/
function utf8_str_pad($input, $length, $padStr = ' ', $type = STR_PAD_RIGHT)
{
    $inputLen = utf8_strlen($input);
    if ($length <= $inputLen) {
        return $input;
    }
    $padStrLen = utf8_strlen($padStr);
    $padLen = $length - $inputLen;
    if ($type == STR_PAD_RIGHT) {
        $repeatTimes = ceil($padLen / $padStrLen);
        return utf8_substr($input . str_repeat($padStr, $repeatTimes), 0, $length);
    }
    if ($type == STR_PAD_LEFT) {
        $repeatTimes = ceil($padLen / $padStrLen);
        return utf8_substr(str_repeat($padStr, $repeatTimes), 0, floor($padLen)) . $input;
    }
    if ($type == STR_PAD_BOTH) {
        $padLen /= 2;
        $padAmountLeft = floor($padLen);
        $padAmountRight = ceil($padLen);
        $repeatTimesLeft = ceil($padAmountLeft / $padStrLen);
        $repeatTimesRight = ceil($padAmountRight / $padStrLen);
        $paddingLeft = utf8_substr(str_repeat($padStr, $repeatTimesLeft), 0, $padAmountLeft);
        $paddingRight = utf8_substr(str_repeat($padStr, $repeatTimesRight), 0, $padAmountLeft);
        return $paddingLeft . $input . $paddingRight;
    }
    trigger_error('utf8_str_pad: Unknown padding type (' . $type . ')', E_USER_ERROR);
}
开发者ID:01J,项目名称:topm,代码行数:42,代码来源:str_pad.php

示例3: buildCensorCacheValue

 /**
  * Builds the regex and censor cache value for a find/replace pair
  *
  * @param string $find
  * @param string $replace
  *
  * @return array|bool
  */
 public static function buildCensorCacheValue($find, $replace)
 {
     $find = trim(strval($find));
     if ($find === '') {
         return false;
     }
     $prefixWildCard = preg_match('#^\\*#', $find);
     $suffixWildCard = preg_match('#\\*$#', $find);
     $replace = is_int($replace) ? '' : trim(strval($replace));
     if ($replace === '') {
         $replace = utf8_strlen($find);
         if ($prefixWildCard) {
             $replace--;
         }
         if ($suffixWildCard) {
             $replace--;
         }
     }
     $regexFind = $find;
     if ($prefixWildCard) {
         $regexFind = substr($regexFind, 1);
     }
     if ($suffixWildCard) {
         $regexFind = substr($regexFind, 0, -1);
     }
     if (!strlen($regexFind)) {
         return false;
     }
     $regex = '#' . ($prefixWildCard ? '' : '(?<=\\W|^)') . preg_quote($regexFind, '#') . ($suffixWildCard ? '' : '(?=\\W|$)') . '#iu';
     return array('word' => $find, 'regex' => $regex, 'replace' => $replace);
 }
开发者ID:namgiangle90,项目名称:tokyobaito,代码行数:39,代码来源:CensorWords.php

示例4: validate

 public function validate()
 {
     $this->language->load('module/pim_localfilesystem');
     $error = array();
     if (utf8_strlen($this->request->post['alias']) < 1 || utf8_strlen($this->request->post['alias']) > 64) {
         $error['error_localfilesystem_alias'] = $this->language->get('error_localfilesystem_alias');
     } else {
         if (!isset($this->request->get['alias']) || isset($this->request->get['alias']) && $this->request->get['alias'] != $this->request->post['alias']) {
             // check if this volume alias already exist.
             $current_volumes = $this->config->get('pim_volumes');
             if (!empty($current_volumes) && is_array($current_volumes)) {
                 foreach ($current_volumes as $key => $volume) {
                     if (is_array($volume)) {
                         foreach ($volume as $vkey => $val) {
                             if ($vkey == $this->request->post['alias']) {
                                 $error['error_alias_exist'] = $this->language->get('error_alias_exist');
                             }
                         }
                     }
                 }
             }
         }
     }
     if (utf8_strlen($this->request->post['path']) < 1 || utf8_strlen($this->request->post['path']) > 600) {
         $error['error_localfilesystem_path'] = $this->language->get('error_localfilesystem_path');
     }
     return $error;
 }
开发者ID:vincentgy,项目名称:rubys,代码行数:28,代码来源:pim_localfilesystem.php

示例5: utf8_strrpos

function utf8_strrpos($string, $needle, $offset = NULL) {
	if (is_null($offset)) {
		$data = explode($needle, $string);

		if (count($data) > 1) {
			array_pop($data);

			$string = join($needle, $data);

			return utf8_strlen($string);
		}

		return false;
	} else {
		if (!is_int($offset)) {
			trigger_error('utf8_strrpos expects parameter 3 to be long', E_USER_WARNING);

			return false;
		}

		$string = utf8_substr($string, $offset);

		if (false !== ($position = utf8_strrpos($string, $needle))) {
			return $position + $offset;
		}

		return false;
	}
}
开发者ID:halfhope,项目名称:ocStore,代码行数:29,代码来源:utf8.php

示例6: index

 public function index($setting = false)
 {
     if (!$setting || !$this->config->get('tracking_input_status') || $setting['language_id'] != $this->config->get('config_language_id') || isset($this->session->data['tracking_input_show']) && !$this->session->data['tracking_input_show'] || $this->config->get('tracking_input_no_cookie_only') && (isset($this->request->request['tracking']) || isset($this->request->cookie['tracking'])) || $this->config->get('tracking_input_show') == 'once' && isset($this->request->cookie['__octfsh__']) && (!isset($this->session->data['tracking_input_show']) || !$this->session->data['tracking_input_show'])) {
         return '';
     }
     $this->document->addScript('catalog/view/javascript/triyp.min.js');
     //$this->document->addScript('catalog/view/javascript/triyp.js');
     $this->session->data['tracking_input_show'] = true;
     if ($this->config->get('tracking_input_show') == 'once') {
         setcookie('__octfsh__', '1', time() + 2592000, '/');
     }
     $data['show_close_button'] = $this->config->get('tracking_input_show_close_button');
     $data['image_close'] = file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/image/close.png') ? 'catalog/view/theme/' . $this->config->get('config_template') . '/image/close.png' : 'catalog/view/theme/default/image/close.png';
     $data['image_loading'] = file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/image/loading.gif') ? 'catalog/view/theme/' . $this->config->get('config_template') . '/image/loading.gif' : 'catalog/view/theme/default/image/loading.gif';
     $data['send_link'] = html_entity_decode($this->url->link('module/tracking_input/send', '', isset($this->request->server['HTTPS']) && $this->request->server['HTTPS'] == 'on' ? 'SSL' : 'NONSSL'), ENT_QUOTES, 'UTF-8');
     $data['close_link'] = html_entity_decode($this->url->link('module/tracking_input/close', '', isset($this->request->server['HTTPS']) && $this->request->server['HTTPS'] == 'on' ? 'SSL' : 'NONSSL'), ENT_QUOTES, 'UTF-8');
     $data['text_thankyou'] = isset($setting['text_thankyou']) && utf8_strlen($setting['text_thankyou']) > 0 ? addcslashes(str_replace(array("\r\n", "\n", "\r"), array(' ', ' ', ' '), html_entity_decode($setting['text_thankyou'], ENT_QUOTES, 'UTF-8')), "'") : '';
     $data['error_message'] = isset($setting['error_message']) && utf8_strlen($setting['error_message']) > 0 ? addcslashes(str_replace(array("\r\n", "\n", "\r"), array(' ', ' ', ' '), html_entity_decode($setting['error_message'], ENT_QUOTES, 'UTF-8')), "'") : '';
     $data['json'] = array();
     foreach (array('send_link', 'close_link', 'text_thankyou', 'error_message') as $_v) {
         $data['json'][$_v] = $data[$_v];
     }
     $data['json'] = json_encode($data['json']);
     $data['text_message'] = html_entity_decode($setting['text'], ENT_QUOTES, 'UTF-8');
     $data['text_heading'] = html_entity_decode($setting['text_heading'], ENT_QUOTES, 'UTF-8');
     $data['send_button'] = $setting['button'];
     $this->language->load('affiliate/tracking_input');
     $data['text_loading'] = $this->language->get('text_please_wait');
     $_tpl = '/template/module/tracking_input_' . (isset($setting['template']) ? $setting['template'] : 'default_' . (substr($setting['position'], 0, 3) === 'col' ? 'column' : 'row')) . '.tpl';
     $_tpl = (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . $_tpl) ? $this->config->get('config_template') : 'default') . $_tpl;
     return $this->load->view($_tpl, $data);
 }
开发者ID:pedrocones,项目名称:store,代码行数:32,代码来源:tracking_input.php

示例7: _preSave

 protected function _preSave()
 {
     if ($this->isChanged('req_message')) {
         $reqMessage = $this->get('req_message');
         $maxLength = 140;
         $reqMessage = preg_replace('/\\r?\\n/', ' ', $reqMessage);
         if (utf8_strlen($reqMessage) > $maxLength) {
             $this->error(new XenForo_Phrase('please_enter_message_with_no_more_than_x_characters', array('count' => $maxLength)), 'req_message');
         }
         $this->set('req_message', $reqMessage);
     }
     $maxTeams = 999;
     // secure?
     if ($this->isInsert()) {
         if ($this->_getMemberModel()->countAllTeamsForUser($this->get('user_id')) >= $maxTeams) {
             $this->error(new XenForo_Phrase('Teams_you_only_join_x_teams', array('max' => $maxTeams)));
         }
     }
     if ($this->get('user_id')) {
         $user = $this->_getUserModel()->getUserById($this->get('user_id'));
         if ($user) {
             $this->set('username', $user['username']);
         } else {
             $this->set('user_id', 0);
         }
     }
     if ($this->get('action_user_id')) {
         $user = $this->_getUserModel()->getUserById($this->get('action_user_id'));
         if ($user) {
             if ($user['username'] != $this->get('action_username')) {
                 $this->set('action_username', $user['username']);
             }
         }
     }
 }
开发者ID:Sywooch,项目名称:forums,代码行数:35,代码来源:Member.php

示例8: validate_password

function validate_password($password)
{
    global $pwd_policy;
    if (isset($pwd_policy)) {
        // Set up regular expressions.  Use p{Ll} instead of [a-z] etc.
        // to make sure accented characters are included
        $pattern = array('alpha' => '/\\p{L}/', 'lower' => '/\\p{Ll}/', 'upper' => '/\\p{Lu}/', 'numeric' => '/\\p{N}/', 'special' => '/[^\\p{L}|\\p{N}]/');
        // Check for conformance to each rule
        foreach ($pwd_policy as $rule => $value) {
            switch ($rule) {
                case 'length':
                    if (utf8_strlen($password) < $pwd_policy[$rule]) {
                        return FALSE;
                    }
                    break;
                default:
                    // turn on Unicode matching
                    $pattern[$rule] .= 'u';
                    $n = preg_match_all($pattern[$rule], $password, $matches);
                    if ($n === FALSE || $n < $pwd_policy[$rule]) {
                        return FALSE;
                    }
                    break;
            }
        }
    }
    // Everything is OK
    return TRUE;
}
开发者ID:ailurus1991,项目名称:MRBS,代码行数:29,代码来源:edit_users.php

示例9: validate

 public function validate()
 {
     if (utf8_strlen($this->request->post['email']) > 96 || !preg_match('/^[^\\@]+@.*.[a-z]{2,15}$/i', $this->request->post['email'])) {
         $this->error['email'] = $this->language->get('error_email');
     }
     return !$this->error;
 }
开发者ID:agyrafa,项目名称:module-newsletter-opencart,代码行数:7,代码来源:newsletter.php

示例10: explodeTags

 public static function explodeTags($tagsStr)
 {
     // sondh@2013-03-27
     // process the string manually to make sure unicode character works
     $len = utf8_strlen($tagsStr);
     $tags = array();
     $start = 0;
     $i = 0;
     while ($i <= $len) {
         if ($i < $len) {
             $char = utf8_substr($tagsStr, $i, 1);
         } else {
             $char = false;
         }
         if ($char === false or preg_match('/^' . Tinhte_XenTag_Constants::REGEX_SEPARATOR . '$/', $char)) {
             // this is a separator
             $tagLen = $i - $start;
             if ($tagLen > 0) {
                 $tags[] = utf8_substr($tagsStr, $start, $tagLen);
             }
             // skip the separator for the next tag
             $start = $i + 1;
         } else {
             // this is some other character
         }
         $i++;
     }
     return $tags;
 }
开发者ID:Sywooch,项目名称:forums,代码行数:29,代码来源:Helper.php

示例11: update

 public static function update($targetClass, $targetPath, $sourceClass, $sourcesContents)
 {
     $targetContents = str_replace($sourceClass, $targetClass, $sourcesContents);
     $php = '<?php';
     $pos = utf8_strpos($targetContents, $php);
     if ($pos !== false) {
         $replacement = sprintf("%s\n\n// updated by %s at %s", $php, __CLASS__, date('c'));
         $targetContents = utf8_substr_replace($targetContents, $replacement, $pos, utf8_strlen($php));
     }
     $classPrefix = substr($targetClass, 0, strpos($targetClass, 'ShippableHelper_'));
     $offset = 0;
     while (true) {
         if (!preg_match('#DevHelper_Helper_ShippableHelper_[a-zA-Z_]+#', $targetContents, $matches, PREG_OFFSET_CAPTURE, $offset)) {
             break;
         }
         $siblingSourceClass = $matches[0][0];
         $offset = $matches[0][1];
         $siblingTargetClass = str_replace('DevHelper_Helper_', $classPrefix, $siblingSourceClass);
         $targetContents = substr_replace($targetContents, $siblingTargetClass, $offset, strlen($siblingSourceClass));
         class_exists($siblingTargetClass);
         $offset += 1;
     }
     $targetContents = preg_replace('#\\* @version \\d+\\s*\\n#', '$0 * @see ' . $sourceClass . "\n", $targetContents, -1, $count);
     return DevHelper_Generator_File::filePutContents($targetPath, $targetContents);
 }
开发者ID:maitandat1507,项目名称:DevHelper,代码行数:25,代码来源:ShippableHelper.php

示例12: IsCorrectLenght

 public static function IsCorrectLenght($text, $min, $max)
 {
     if (utf8_strlen($text) < $min || utf8_strlen($text) > $max) {
         return false;
     }
     return true;
 }
开发者ID:akrex,项目名称:taskmanager,代码行数:7,代码来源:validator.php

示例13: validate_configure

 public function validate_configure()
 {
     $json = array();
     if ($this->request->post['database'] == 'mysqli') {
         $connection = @new mysqli($this->request->post['database_hostname'], $this->request->post['database_username'], $this->request->post['database_password'], $this->request->post['database_name']);
         if ($connection->connect_error) {
             $json['error'] = $connection->connect_error;
         } else {
             $connection->close();
         }
     }
     if ($this->request->post['database'] == 'mysql') {
         $connection = @mysql_connect($this->request->post['database_hostname'], $this->request->post['database_username'], $this->request->post['database_password']);
         if (!$connection) {
             $json['error'] = $this->language->get('error_connection');
         } else {
             if (!@mysql_select_db($this->request->post['database_name'], $connection)) {
                 $json['error'] = $this->language->get('error_database');
             }
             mysql_close($connection);
         }
     }
     if (utf8_strlen($this->request->post['admin_username']) < 3 || utf8_strlen($this->request->post['admin_username']) > 32) {
         $json['error'] = $this->language->get('error_username');
     }
     if (utf8_strlen($this->request->post['admin_password']) < 6 || utf8_strlen($this->request->post['admin_password']) > 25) {
         $json['error'] = $this->language->get('error_password');
     }
     if (utf8_strlen($this->request->post['admin_email']) > 96 || !preg_match('/^[^\\@]+@.*.[a-z]{2,15}$/i', $this->request->post['admin_email'])) {
         $json['error'] = $this->language->get('error_email');
     }
     $this->response->addHeader('Content-Type: application/json');
     $this->response->setOutput(json_encode($json));
 }
开发者ID:mehulsbhatt,项目名称:Logic-Invoice,代码行数:34,代码来源:install.php

示例14: convertEditorHtmlToBbCode

 /**
  * Converts WYSIWYG editor HTML back to BB code
  *
  * @param string $messageTextHtml HTML to convert
  * @param XenForo_Input $input
  * @param integer $htmlCharacterLimit Max length of HTML before processing; defaults to 4 * message length option
  *
  * @return string BB code input
  */
 public function convertEditorHtmlToBbCode($messageTextHtml, XenForo_Input $input, $htmlCharacterLimit = -1)
 {
     if ($htmlCharacterLimit < 0) {
         $htmlCharacterLimit = 4 * XenForo_Application::get('options')->messageMaxLength;
         // quadruple the limit as HTML can be a lot more verbose
     }
     if ($htmlCharacterLimit && utf8_strlen($messageTextHtml) > $htmlCharacterLimit) {
         throw new XenForo_Exception(new XenForo_Phrase('submitted_message_is_too_long_to_be_processed'), true);
     }
     $options = array();
     $requestPaths = XenForo_Application::get('requestPaths');
     $options['baseUrl'] = $requestPaths['fullBasePath'];
     $relativeResolver = $input->filterSingle('_xfRelativeResolver', XenForo_Input::STRING);
     if ($relativeResolver && isset($_SERVER['HTTP_USER_AGENT'])) {
         if (preg_match('#Firefox/([0-9]+)\\.([0-9]+)\\.([0-9]+)#i', $_SERVER['HTTP_USER_AGENT'], $match)) {
             // FF versions sometime before 3.6.12 have an issue with respecting the base tag of the editor,
             // 3.6.8 is a known version that has problems
             $useResolver = $match[1] <= 3 && $match[2] <= 6 && $match[3] <= 8;
         } else {
             $useResolver = false;
         }
         if ($useResolver) {
             // take off query string and then up to the last directory
             $relativeResolver = preg_replace('/\\?.*$/', '', $relativeResolver);
             $relativeResolver = preg_replace('#/[^/]+$#', '', $relativeResolver);
             $options['baseUrl'] = $relativeResolver;
         }
     }
     $rendered = XenForo_Html_Renderer_BbCode::renderFromHtml($messageTextHtml, $options);
     return trim(XenForo_Input::cleanString($rendered));
 }
开发者ID:VoDongMy,项目名称:xenforo-laravel5.1,代码行数:40,代码来源:Editor.php

示例15: formatUserNameMobile

function formatUserNameMobile($ID, $login, $realname, $firstname, $link = 0, $cut = 0)
{
    global $CFG_GLPI;
    $before = "";
    $after = "";
    $viewID = "";
    if (strlen($realname) > 0) {
        $temp = $realname;
        if (strlen($firstname) > 0) {
            if ($CFG_GLPI["names_format"] == FIRSTNAME_BEFORE) {
                $temp = $firstname . " " . $temp;
            } else {
                $temp .= " " . $firstname;
            }
        }
        if ($cut > 0 && utf8_strlen($temp) > $cut) {
            $temp = utf8_substr($temp, 0, $cut);
            $temp .= " ...";
        }
    } else {
        $temp = $login;
    }
    if ($ID > 0 && (strlen($temp) == 0 || $_SESSION["glpiis_ids_visible"])) {
        $viewID = "&nbsp;({$ID})";
    }
    if ($link == 1 && $ID > 0) {
        /*$before="<a title=\"".$temp."\"
          href=\"".$CFG_GLPI["root_doc"]."/front/user.form.php?id=".$ID."\">";*/
        $before = "<a title=\"" . $temp . "\"\n                  href=\"item.php?itemtype=user&menu=" . $_GET['menu'] . "&ssmenu=" . $_GET['ssmenu'] . "&id=" . $ID . "\" data-back='false'>";
        $after = "</a>";
    }
    //$username=$before.$temp.$viewID.$after;
    $username = $temp . $viewID;
    return $username;
}
开发者ID:JULIO8,项目名称:respaldo_glpi,代码行数:35,代码来源:common.function.php


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