简体   繁体   中英

Call to undefined method after upgrading to PHP 5.4.0

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM