本文整理汇总了PHP中SpoonFilter::isMaximumCharacters方法的典型用法代码示例。如果您正苦于以下问题:PHP SpoonFilter::isMaximumCharacters方法的具体用法?PHP SpoonFilter::isMaximumCharacters怎么用?PHP SpoonFilter::isMaximumCharacters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SpoonFilter
的用法示例。
在下文中一共展示了SpoonFilter::isMaximumCharacters方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isMaximumCharacters
/**
* Checks if this field's length is less than or equal to the given maximum.
*
* @return bool
* @param int $maximum The maximum number of characters.
* @param string[optional] $error The error message to set.
*/
public function isMaximumCharacters($maximum, $error = null)
{
// filled
if ($this->isFilled()) {
// post/get data
$data = $this->getMethod(true);
// validate
if (!isset($data[$this->attributes['name']]) || !SpoonFilter::isMaximumCharacters($maximum, $data[$this->attributes['name']])) {
if ($error !== null) {
$this->setError($error);
}
return false;
}
return true;
}
// not submitted
if ($error !== null) {
$this->setError($error);
}
return false;
}
示例2: testIsMaximumCharacters
public function testIsMaximumCharacters()
{
$string = 'Ik heb er géén gedacht van';
$this->assertTrue(SpoonFilter::isMaximumCharacters(26, $string, 'utf-8'));
$this->assertFalse(SpoonFilter::isMaximumCharacters(10, $string, 'utf-8'));
$this->assertTrue(SpoonFilter::isMaximumCharacters(26, utf8_decode($string), 'iso-8859-1'));
}