本文整理匯總了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'));
}