本文整理汇总了PHP中Check::data方法的典型用法代码示例。如果您正苦于以下问题:PHP Check::data方法的具体用法?PHP Check::data怎么用?PHP Check::data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Check
的用法示例。
在下文中一共展示了Check::data方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Name
public static function Name($name)
{
self::$format = array();
self::$format['a'] = 'ÀÁÂÃÄÅÆÇçÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜüÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿŔŕ"!@#$%&*()_-+={[}]/?;:.,\\\'<>°ºª';
self::$format['b'] = 'aaaaaaacceeeeiiiidnoooooouuuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyRr ';
self::$data = strtr(utf8_decode($name), utf8_decode(self::$format['a']), self::$format['b']);
self::$data = strip_tags(trim(self::$data));
self::$data = str_replace(' ', '-', self::$data);
self::$data = str_replace(array('-----', '----', '---', '--'), '-', self::$data);
return strtolower(utf8_encode(self::$data));
}
示例2: valid
public static function valid($rules, $data)
{
static::$errors = [];
static::triggerOnce('init');
self::$data = $data = (array) $data;
foreach ((array) $rules as $field_name => $rule) {
$current = isset($data[$field_name]) ? $data[$field_name] : null;
if (is_callable($rule)) {
static::$errors[$field_name] = call_user_func($rule, $current);
continue;
} elseif (is_string($rule)) {
$current_rules = array_flip(preg_split('/\\s*\\|\\s*/', $rule));
} else {
$current_rules = (array) $rule;
}
static::$errors[$field_name] = true;
foreach ($current_rules as $method => $message) {
$meth_name = strtok($method, ':');
$opts = strtok(':') ?: '';
$opts = $opts ? json_decode("[{$opts}]") : [];
$meth_opts = $opts ? array_merge([$current], $opts) : [$current];
if (static::$errors[$field_name] !== true) {
continue 2;
}
if (empty(static::$methods[$meth_name])) {
static::$errors[$field_name] = true;
} else {
if (call_user_func_array(static::$methods[$meth_name]->validate, $meth_opts)) {
static::$errors[$field_name] = true;
} else {
$arg = [];
foreach ($meth_opts as $key => $value) {
$arg["arg_{$key}"] = $value;
}
static::$errors[$field_name] = Text::render(static::$methods[$meth_name]->message, $arg);
}
}
}
}
self::$data = [];
// Clean non-errors
static::$errors = array_filter(static::$errors, function ($v) {
return $v !== true;
});
return empty(static::$errors);
}