Call to undefined method after upgrading to PHP 5.4.0

前提是你 提交于 2019-12-12 15:24:35

问题


Stumped by this one. This code is giving me

PHP Fatal error: Call to undefined method MyObject::helloWorld()

But only the second time I run it, the first time it runs fine.

class MyObject
{

  function __construct()
  {
    echo("creating MyObject...");
  }


  public function helloWorld()
  {
    echo("Hello World!");
  }


}

$obj = new MyObject();
$obj->helloWorld();

I also see "creating MyObject..." generated the second time, but not "Hello World!".

I'm in the process of upgrading to PHP 5.4.0.

I Must be missing something really obvious.


回答1:


This is APC bug... you can apply a patch or disable APC in /etc/php.ini or /etc/php.d/apc.ini depending on your configs.

The first time you run your script the opcode is getting generated and is cached by APC, the second time you run your script opcode is pulled from APC cache. Because APC cache is bad your script fails on the seconds run.

See this bugs for references php #61219 and php #60658



来源:https://stackoverflow.com/questions/10342738/call-to-undefined-method-after-upgrading-to-php-5-4-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!