本文整理匯總了PHP中Laravel\Str::length方法的典型用法代碼示例。如果您正苦於以下問題:PHP Str::length方法的具體用法?PHP Str::length怎麽用?PHP Str::length使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Laravel\Str
的用法示例。
在下文中一共展示了Str::length方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: size
/**
* Get the size of an attribute.
*
* @param string $attribute
* @param mixed $value
* @return mixed
*/
protected function size($attribute, $value)
{
// This method will determine if the attribute is a number, string, or file and
// return the proper size accordingly. If it is a number, then number itself is
// the size; if it is a file, the size is kilobytes in the size; if it is a
// string, the length is the size.
if (is_numeric($value) and $this->has_rule($attribute, $this->numeric_rules)) {
return $this->attributes[$attribute];
} elseif (array_key_exists($attribute, Input::file())) {
return $value['size'] / 1024;
} else {
return Str::length(trim($value));
}
}
示例2: size
/**
* Get the size of an attribute.
*
* This method will determine if the attribute is a number, string, or file and
* return the proper size accordingly. If it is a number, then number itself is
* the size; if it is a file, the size is kilobytes in the size; if it is a
* string, the length is the size.
*
* @param string $attribute
* @param mixed $value
* @return mixed
*/
protected function size($attribute, $value)
{
if (is_numeric($value) and $this->has_rule($attribute, $this->numeric_rules)) {
return $this->attributes[$attribute];
} elseif (array_key_exists($attribute, Input::file())) {
return $value['size'] / 1024;
} else {
return Str::length(trim($value));
}
}