【发布时间】:2010-11-24 18:20:50
【问题描述】:
我在第 4 行遇到错误
解析错误:语法错误,第 21 行 C:\xampp\htdocs\work\CASC\admin\form-validator.php 中的意外 T_FUNCTION
有人可以帮忙吗?
public function email($message='')
{
$message = ( empty ($message) ) ? '%s is an invalid email address.' : $message;
$this->set_rule(__FUNCTION__, function($email) {
return ( filter_var($email, FILTER_VALIDATE_EMAIL) === FALSE ) ? FALSE : TRUE;
}, $message);
return $this;
}
private function set_rule($rule, $function, $message='')
{
// do not attempt to validate when no post data is present
if ( $this->haspostdata ) {
if ( ! array_key_exists($rule, $this->rules) ) {
$this->rules[$rule] = TRUE;
if ( ! array_key_exists($rule, $this->functions) && is_callable($function) ) {
$this->functions[$rule] = $function;
}
if ( !empty ($message) ) {
$this->messages[$rule] = $message;
}
}
}
}
【问题讨论】:
-
是
set_rule()期望作为第二个参数关闭? -
我已编辑问题,请立即查看