调试 PHP
我使用 xdebug 来调试和理解 php 项目中的代码已经有一段时间了,有时会遇到不清楚 PHP 内部发生了什么的情况。
是否可以设置 xdebug 或 gdb 以便我可以跟踪实际的 php 内置函数?
I've been using xdebug to debug and understand code in php projects for a while now, and have sometimes come into situations where it's been unclear what's going on inside of PHP.
Is it possible to set xdebug or gdb up so that i can trace into actual php builtin functions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
如果您使用的是 macOS、solaris 或最新的 freebsd 系统,您可以对其进行一些 dtrace。 对于那些无数“PHP 到底在做什么?”的人来说,它可以派上用场。 时刻。
If you are using a macosx, solaris or recent freebsd system you can throw a little dtrace at it. It can come in handy for those all too numerous "WTF is PHP doing?" moments.
我对此表示怀疑,xdebug 的目的是跟踪你的 PHP 代码,而不是内部结构。 内部被认为是无错误的(显然有时并非如此,但这超出了 xdebug 的范围)。
如果您想知道内置函数的作用,您可以随时查看 PHP 源代码,但这有时非常棘手。 当我想知道 PHP 手册文档会做什么时,PHP 手册文档总是对我很有帮助。
I doubt it, xdebug is intended for tracing your PHP code, not the internals. The internals are assumed to be bug-free (which obviously they aren't sometimes, but that's beyond the scope of xdebug).
You can always look at the PHP source if you want to know what the built-in functions do, but that's sometimes pretty hairy. The PHP manual docs have always served me well enough when I want to know what they'll do.
如果您使用调试符号编译了 php,则可以使用 gdb 跟踪 C 级代码。 从这里开始:
http://derickrethans.nl/phps_segmentation_faults_gdbfu.php
You can use gdb to trace in to the C-level code, provided you have php compiled with debug symbols. Have a look here for a start:
http://derickrethans.nl/phps_segmentation_faults_gdbfu.php
测试 Zend 引擎输出的一种方法是查看操作码,您可以使用 Derick Rethan 的VLD(Vulcan Logic Dissasembler),它似乎也在 PECL。 注意:仅适用于 *nix 系统(请参阅站点了解要求)。
调试这些操作码的一些示例可以在Sara Golemon 的博客上找到,在诸如 了解操作码 和 < a href="http://blog.libssh2.org/index.php?/archives/28-How-long-is-a-piece-of-string.html" rel="nofollow noreferrer">a 有多长一段绳子?。
One way to test the output of the Zend engine, to peek inside at the opcodes, you can use Derick Rethan's VLD (Vulcan Logic Dissasembler), which also appears to be on PECL. Note: only works on *nix systems (see site for requirements).
Some examples of debugging these opcodes can be found on Sara Golemon's blog, in articles such as Understanding Opcodes and How long is a piece of string?.
还有很棒的 Google Chrome 扩展 PHP 控制台,其中 php 库 允许:
推荐给大家!
There is also great Google Chrome extension PHP Console with php library that allows to:
Recommend to everyone!