升级到PHP 5.4.0后,调用未定义的方法 [英] Call to undefined method after upgrading to PHP 5.4.0

查看:91
本文介绍了升级到PHP 5.4.0后,调用未定义的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

被这个困扰.这段代码给了我

Stumped by this one. This code is giving me

PHP致命错误:调用未定义的方法MyObject :: helloWorld()

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();

我还看到第二次生成了正在创建MyObject ...",但没有看到"Hello World!".

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

我正在升级到PHP 5.4.0.

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

我肯定想念一些明显的东西.

I Must be missing something really obvious.

推荐答案

这是APC错误...您可以根据您的配置在/etc/php.ini/etc/php.d/apc.ini中应用补丁或禁用APC.

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.

第一次运行脚本时,操作码将生成并由APC缓存,第二次运行脚本时,操作码将从APC缓存中提取.由于APC缓存不良,因此您的脚本在运行秒数时就会失败.

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.

请参阅此错误以获取参考 php#61219

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

这篇关于升级到PHP 5.4.0后,调用未定义的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆