在PHP中使用回调函数时的问题 [英] Problems while using a callback function in PHP

查看:98
本文介绍了在PHP中使用回调函数时的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到此问题时使用回调函数

I am having this problem When using callback functions

Class My_Class {

     public function my_function() {

            $pad = function($value) {
            return str_pad($value, 2, '0', STR_PAD_LEFT);
            };

            function pad_function($value) {
                 return str_pad($value, 2, '0', STR_PAD_LEFT);
            }

            array_map($pad, range(0,100)); //This fails with an exception "Invalid opcode 153/1/8."
            array_map("pad_function", range(0,100)); //This works ok
        }



}


b $ b

我使用PHP版本5.3.3-7。

I am using PHP version 5.3.3-7.

有任何想法为什么会发生这种情况?

Any ideas of why this is happening?

提前感谢!

推荐答案

最后问题出在eaccelerator。

Finally the problem was with eaccelerator.

执行程式码时,eaccelerator版本1.0-dev会被删除。
版本0.9.6.1的eaccelerator不会与代码崩溃。

Version 1.0-dev of eaccelerator carashes when executing the code. Version 0.9.6.1 of eaccelerator does not crash with the code.

这篇关于在PHP中使用回调函数时的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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