本文整理汇总了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));
}
}