Php 当我使用回调函数时,为什么我当前使用的页面中会出现404

Php 当我使用回调函数时,为什么我当前使用的页面中会出现404,php,kohana,Php,Kohana,这是控制器函数寄存器() 这是回调函数 public function _username_exists(Validation $post) { // if add_rules validation found any errors, exit if (array_key_exists('uname', $post->errors())) return; $result = $this->user->check_user

这是控制器函数寄存器()

这是回调函数

public function _username_exists(Validation $post)
    {
        // if add_rules validation found any errors, exit
        if (array_key_exists('uname', $post->errors())) return;

        $result = $this->user->check_username_exists($username);
        if (!$result)
        {
            //add error to validation object
            $post->add_error('uname', 'username_exists');
        }
    }

如果我注释掉对回调函数的调用,效果会非常好。

在add\u callback方法的方法名字符串中有一个空格

$post->add_callbacks('uname', array($this, ' _username_exists'));
应该是

$post->add_callbacks('uname', array($this, '_username_exists'));
我想这会解决问题。

也许你的意思是“如果我发表评论”?
$post->add_callbacks('uname', array($this, '_username_exists'));