本文整理汇总了PHP中Nette\String::length方法的典型用法代码示例。如果您正苦于以下问题:PHP String::length方法的具体用法?PHP String::length怎么用?PHP String::length使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\String
的用法示例。
在下文中一共展示了String::length方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkMaxLength
/**
* Filter: shortens value to control's max length.
* @return string
*/
public function checkMaxLength($value)
{
if ($this->control->maxlength && Nette\String::length($value) > $this->control->maxlength) {
$value = iconv_substr($value, 0, $this->control->maxlength, 'UTF-8');
}
return $value;
}
示例2: sanitize
/**
* Filter: removes unnecessary whitespace and shortens value to control's max length.
* @return string
*/
public function sanitize($value)
{
if ($this->control->maxlength && Nette\String::length($value) > $this->control->maxlength) {
$value = iconv_substr($value, 0, $this->control->maxlength, 'UTF-8');
}
return Nette\String::trim(strtr($value, "\r\n", ' '));
}
示例3: validateLength
/**
* Length validator: is control's value length in range?
* @param TextBase
* @param array min and max length pair
* @return bool
*/
public static function validateLength(TextBase $control, $range)
{
if (!is_array($range)) {
$range = array($range, $range);
}
$len = String::length($control->getValue());
return ($range[0] === NULL || $len >= $range[0]) && ($range[1] === NULL || $len <= $range[1]);
}
示例4: length
/**
* Returns array of string length.
* @param mixed
* @return int
*/
public static function length($var)
{
return is_string($var) ? String::length($var) : count($var);
}