PHP 5.4 无法识别父常量

PHP 5.4 does not recognize parent constant

我迁移了我的云服务器,在安装所有 lamp 东西并克隆我的存储库后,我的 php 只是无法识别 'parent' 常量。

我的日志说。

[Wed Jul 08 21:29:28 2015] [error] [client 186.223.169.223] PHP Notice: Use of undefined constant parent - assumed 'parent' in /home/dev/xxx/Funcionario.php on line 11, referer: xxx

在代码中我有

class Funcionario extends Model {

    protected function init() {
        $this -> db = DataBase::getInstance('000001');

        call_user_func_array(array( parent, 'init'), func_get_args() );
    }
}

观察。 PHP-5.4

谢谢。

Use of undefined constant parent - assumed 'parent'

这是因为 parent 后面没有作用域运算符 :: 被认为是常量;如果你把它变成一个字符串,它就可以正常工作:

call_user_func_array(array('parent', 'init'), func_get_args());

没有它也能正常工作,您现在看到该通知的唯一原因是 error_reporting 级别不同。