我发现了 php 在动态调用不同类时的有趣行为。 由于某种原因,类名被打乱了,它看起来像散列字符串的一部分。
这是我尝试执行的 php 代码示例:
call_user_func(array('app_event', 'arrayItems'));
这里是这个事件的回溯:
Array
(
[0] => Array
(
[function] => autoLoader
[class] => init
[type] => ::
[args] => Array
(
[0] => j7ltlqmoy
)
)
[1] => Array
(
[function] => spl_autoload_call
[args] => Array
(
[0] => j7ltlqmoy
)
)
[2] => Array
(
[file] => /site/class.app.php
[line] => 107
[function] => call_user_func
[args] => Array
(
[0] => Array
(
[0] => app_event
[1] => arrayItems
)
)
)
...
);
任何人都可以解释我做错了什么以及什么会导致 sting app_event 被翻译成 j7ltlqmoy?
更新
脚本确实适用于所有其他类,并且仅在未实现请求的方法时才会抛出此奇怪的文本。我已经设法让我的应用程序正常工作,但它仍然没有解释为什么它会打乱名称而不是抛出错误?
更新 2
当您尝试静态调用方法并且未声明静态属性时,也会发生此事件(在 PHP 5.3.10 上测试)。可以通过将方法声明为静态来修复。
更新 3
正如在对我的 bug report 的评论中提到的,此问题是由 Zend Guard Loader
最佳答案
如对我的 bug report 的评论中所述,此问题是由 Zend Guard Loader
引起的关于php - 通过 call_user_func 传递给 spl_autoload_call 的乱码类名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3517789/