本文整理匯總了PHP中v::in方法的典型用法代碼示例。如果您正苦於以下問題:PHP v::in方法的具體用法?PHP v::in怎麽用?PHP v::in使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類v
的用法示例。
在下文中一共展示了v::in方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testIn
public function testIn()
{
$this->assertTrue(v::in('a', array('a', 'b', 'c')));
$this->assertFalse(v::in('a', array('b', 'c', 'd')));
}
示例2: hasError
/**
* @param string $key (optional) the key of the form field to check.
*
* @return true if there are erroneous fields. If a key is given, returns
* true if this field is erroneous. Returns false otherwise.
*
*/
public function hasError($key)
{
return $key ? v::in($key, $this->erroneousFields) : !empty($this->erroneousFields);
}
示例3: function
}, 'email' => function ($value) {
return filter_var($value, FILTER_VALIDATE_EMAIL) !== false;
}, 'filename' => function ($value) {
return v::match($value, '/^[a-z0-9@._-]+$/i') && v::min($value, 2);
}, 'in' => function ($value, $in) {
return in_array($value, $in, true);
}, 'integer' => function ($value) {
return filter_var($value, FILTER_VALIDATE_INT) !== false;
}, 'ip' => function ($value) {
return filter_var($value, FILTER_VALIDATE_IP) !== false;
}, 'match' => function ($value, $preg) {
return preg_match($preg, $value) > 0;
}, 'max' => function ($value, $max) {
return size($value) <= $max;
}, 'min' => function ($value, $min) {
return size($value) >= $min;
}, 'notIn' => function ($value, $notIn) {
return !v::in($value, $notIn);
}, 'num' => function ($value) {
return is_numeric($value);
}, 'required' => function ($key, $array) {
return !empty($array[$key]);
}, 'same' => function ($value, $other) {
return $value === $other;
}, 'size' => function ($value, $size) {
return size($value) == $size;
}, 'url' => function ($value) {
// In search for the perfect regular expression: https://mathiasbynens.be/demo/url-regex
$regex = '_^(?:(?:https?|ftp)://)(?:\\S+(?::\\S*)?@)?(?:(?!10(?:\\.\\d{1,3}){3})(?!127(?:\\.\\d{1,3}){3})(?!169\\.254(?:\\.\\d{1,3}){2})(?!192\\.168(?:\\.\\d{1,3}){2})(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z\\x{00a1}-\\x{ffff}0-9]+-?)*[a-z\\x{00a1}-\\x{ffff}0-9]+)(?:\\.(?:[a-z\\x{00a1}-\\x{ffff}0-9]+-?)*[a-z\\x{00a1}-\\x{ffff}0-9]+)*(?:\\.(?:[a-z\\x{00a1}-\\x{ffff}]{2,})))(?::\\d{2,5})?(?:/[^\\s]*)?$_iu';
return preg_match($regex, $value) !== 0;
});