duanlongling5308 2015-07-09 00:44 采纳率: 0%
浏览 34
已采纳

PHP 5.4无法识别父常量

I migrated my cloud server, and after install all lamp stuff and clone my repository my php just does not recognizes the 'parent' constant.

My log says.

[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

And in code I have

class Funcionario extends Model {

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

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

Obs. PHP-5.4

Thanks.

  • 写回答

1条回答 默认 最新

  • dongtuo5262 2015-07-09 01:29
    关注

    Use of undefined constant parent - assumed 'parent'

    This is because parent not being followed by the scope operator :: is considered a constant; it works fine if you make it a string:

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

    It works fine without it as well, the only reason why you're seeing that notice now is because of a different error_reporting level.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输