本文整理汇总了PHP中get_mb_len函数的典型用法代码示例。如果您正苦于以下问题:PHP get_mb_len函数的具体用法?PHP get_mb_len怎么用?PHP get_mb_len使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_mb_len函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: transferCategories
function transferCategories()
{
$sSql = "SELECT \r\n \t\t\t`CategoryID` AS `id`, \r\n \t\t\t`CategoryName` AS `name`\r\n \t\tFROM `ArticlesCategory`";
$rResult = mysql_query($sSql, $this->rOldDb);
$iCount = mysql_num_rows($rResult);
while ($aCategory = mysql_fetch_assoc($rResult)) {
if (get_mb_len($aCategory['name']) > 32) {
$aCategory['name'] = get_mb_substr($aCategory['name'], 0, 32);
}
if ($this->existsCategory($aCategory['name'], 0, $this->_sType)) {
continue;
}
//escape all values
$aCategory['name'] = $this->oMigrationModule->_oDb->escape($aCategory['name']);
$sSql = "INSERT INTO `sys_categories`(`Category`, `ID`, `Type`, `Owner`, `Status`, `Date`)\r\n \t\t VALUES('" . $aCategory['name'] . "', '0', '" . $this->_sType . "', '0', 'active', NOW())";
$iResult = (int) $this->oDolModule->_oDb->query($sSql);
if ($iResult <= 0) {
$this->setResultStatus('Database error. Cannot insert category in the database.');
return MIGRATION_FAILED;
}
}
return MIGRATION_SUCCESSFUL;
}
示例2: uriGenerate
function uriGenerate($s, $sTable, $sField, $iMaxLen = 255)
{
$s = uriFilter($s);
if (uriCheckUniq($s, $sTable, $sField)) {
return $s;
}
// try to add date
if (get_mb_len($s) > 240) {
$s = get_mb_substr($s, 0, 240);
}
$s .= '-' . date('Y-m-d');
if (uriCheckUniq($s, $sTable, $sField)) {
return $s;
}
// try to add number
for ($i = 0; $i < 999; ++$i) {
if (uriCheckUniq($s . '-' . $i, $sTable, $sField)) {
return $s . '-' . $i;
}
}
return rand(0, 999999999);
}
示例3: checkLength
function checkLength($s, $iLenMin, $iLenMax)
{
if (is_array($s)) {
foreach ($s as $k => $v) {
$iLen = get_mb_len($v);
if ($iLen < $iLenMin || $iLen > $iLenMax) {
return false;
}
}
return true;
}
$iLen = get_mb_len($s);
return $iLen >= $iLenMin && $iLen <= $iLenMax ? true : false;
}
示例4: uriGenerate
function uriGenerate($s, $sTable, $sField, $iMaxLen = 255)
{
//$s = get_mb_replace ('/[^\pL^\pN]+/u', '-', $s); // unicode characters
$s = get_mb_replace('/([^\\d^\\w]+)/', '-', $s);
// latin characters
$s = get_mb_replace('/([-^]+)/', '-', $s);
if (uriCheckUniq($s, $sTable, $sField)) {
return $s;
}
// try to add date
if (get_mb_len($s) > 240) {
$s = get_mb_substr($s, 0, 240);
}
$s .= '-' . date('Y-m-d');
if (uriCheckUniq($s, $sTable, $sField)) {
return $s;
}
// try to add number
for ($i = 0; $i < 999; ++$i) {
if (uriCheckUniq($s . '-' . $i, $sTable, $sField)) {
return $s . '-' . $i;
}
}
return rand(0, 999999999);
}
示例5: uriGenerate
function uriGenerate($s, $sTable, $sField, $sEmpty = '-')
{
$s = uriFilter($s, $sEmpty);
if (uriCheckUniq($s, $sTable, $sField)) {
return $s;
}
// cut off redundant part
if (get_mb_len($s) > 240) {
$s = get_mb_substr($s, 0, 240);
}
// try to add date
$s .= '-' . date('Y-m-d');
if (uriCheckUniq($s, $sTable, $sField)) {
return $s;
}
// try to add number
for ($i = 0; $i < 999; ++$i) {
if (uriCheckUniq($s . '-' . $i, $sTable, $sField)) {
return $s . '-' . $i;
}
}
return rand(0, 999999999);
}
示例6: prepare
/**
* Prepare SQL query before execution if some arguments are need to be passed to it.
* All parameters marked with question (?) symbol in SQL query are replaced with parameters passed after SQL query parameter.
* Parameters are properly excaped and surrounded by qutes if needed.
* Example:
* @code
* $sSql = $oDb->prepare("SELECT `a`, `b` from `t` WHERE `c` = ? and `d` = ?", 12, 'aa');
* echo $sSql;// outputs: SELECT `a`, `b` from `t` WHERE `c` = 12 and `d` = 'aa'
* $a = $oDb->getAll($sSql);
* @endcode
*
* @param string $sQuery SQL query, parameters for replacing are marked with ? symbol
* @param mixed $mixed any number if parameters to replace, number of parameters whould match number of ? symbols in SQL query
* @return string with SQL query ready for execution
*/
function prepare($sQuery)
{
$aArgs = func_get_args();
$sQuery = array_shift($aArgs);
$iPos = 0;
foreach ($aArgs as $mixedArg) {
if (is_null($mixedArg)) {
$s = 'NULL';
} elseif (is_numeric($mixedArg)) {
$s = $mixedArg;
} else {
$s = "'" . mysql_real_escape_string($mixedArg) . "'";
}
$i = bx_mb_strpos($sQuery, '?', $iPos);
$sQuery = bx_mb_substr_replace($sQuery, $s, $i, 1);
$iPos = $i + get_mb_len($s);
}
return $sQuery;
}
示例7: getCorrectUri
function getCorrectUri($sCaption, $iOwnerId = 0, $bCheck = true)
{
$sUri = uriFilter($sCaption);
if (!$sUri) {
$sUri = '-';
}
if (!$bCheck) {
return $sUri;
}
if ($this->checkUriUniq($sUri, $iOwnerId)) {
return $sUri;
}
if (get_mb_len($sUri) > 240) {
$sUri = get_mb_substr($sUri, 0, 240);
}
$sUri .= '-' . date('Y-m-d');
if ($this->checkUriUniq($sUri, $iOwnerId)) {
return $sUri;
}
for ($i = 0; $i < 999; ++$i) {
if ($this->checkUriUniq($sUri . '-' . $i, $iOwnerId)) {
return $sUri . '-' . $i;
}
}
return time();
}