dongsi1954 2014-12-30 08:15
浏览 20
已采纳

如何在PHP中转储用户定义或系统编译的函数?

Is there any way to dump a user defined or system compiled function same as print_r or var_dump for variables in PHP?

for example:

dump('echo');

or

dump('my_function');
  • 写回答

1条回答 默认 最新

  • duana1021 2014-12-30 10:06
    关注

    Such a function would be powerful.

    Some tools outside of PHP will help: A debugger, like gdb; a refactoring tool, like resharper/MonoDev and some tracing tools, like strace/dtrace. You would also use some tools, which expose internals, like Derick's VLD or PVT, which can dump the opcodes to a readable format, from there, it's not totally impossible to (re)create the code from it.

    Especially, in regard to commercial PHP extensions and products, like Zend Core/Platform or Zend Server it would be a reverse engineering / disassembling technique, because you are asking for C/C++ extension code from inside PHP.

    You ain't gonna need this technique!

    The benefit of doing this is some frameworks such as Zend extend some function to PHP global functions such as zend_report_statistics and I want to see their structures in my debug pages because they compiled in dll files.

    There is no real benefit, except debugging, in seeing the interals of a little stats reporting function.

    And by the way, the first thing you would see, when doing a dump('echo'); is, that echo is a language construct and not a function.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?