php方法断点如何实现

美女程序员鼓励师

1、使用 phpdbg_break_function()来给这个testFunc() 方法设置一个断点。当代码中调用这个函数的时候,就会进入这个断点中。

prompt> r

[Breakpoint #0 in testFunc() at /Users/zhangyue/MyDoc/博客文章/dev-blog/php/202006/source/PHPDebug互动扩展.php:11, hits: 1]

>00011: function testFunc(){

 00012:     global $i;

 00013:     $i += 3;

 

prompt> s

[L12         0x109eef620 EXT_STMT                                                                               /Users/zhangyue/MyDoc/博客文章/dev-blog/php/202006/source/PHPDebug互动扩展.php]

>00012:     global $i;

 00013:     $i += 3;

 00014:     echo "This is testFunc! i:" . $i, PHP_EOL;

 

prompt> s

[L12         0x109eef640 BIND_GLOBAL             $i                   "i"                                       /Users/zhangyue/MyDoc/博客文章/dev-blog/php/202006/source/PHPDebug互动扩展.php]

[L13         0x109eef660 EXT_STMT                                                                               /Users/zhangyue/MyDoc/博客文章/dev-blog/php/202006/source/PHPDebug互动扩展.php]

>00013:     $i += 3;

 00014:     echo "This is testFunc! i:" . $i, PHP_EOL;

 00015: }

2、直接进行了两次 s 单步,可以看到 global $i 对应的 opcode 操作是 BIND_GLOBAL 。继续向下操作。

prompt> s

[L13         0x109eef680 ASSIGN_ADD              $i                   3                                         /Users/zhangyue/MyDoc/博客文章/dev-blog/php/202006/source/PHPDebug互动扩展.php]

[L14         0x109eef6a0 EXT_STMT                                                                               /Users/zhangyue/MyDoc/博客文章/dev-blog/php/202006/source/PHPDebug互动扩展.php]

>00014:     echo "This is testFunc! i:" . $i, PHP_EOL;

 00015: }

 00016:

 

prompt> s

[L14         0x109eef6c0 CONCAT                  "This is testFunc!"+ $i                   ~1                   /Users/zhangyue/MyDoc/博客文章/dev-blog/php/202006/source/PHPDebug互动扩展.php]

[L14         0x109eef6e0 ECHO                    ~1                                                             /Users/zhangyue/MyDoc/博客文章/dev-blog/php/202006/source/PHPDebug互动扩展.php]

This is testFunc! i:4

[L14         0x109eef700 EXT_STMT                                                                               /Users/zhangyue/MyDoc/博客文章/dev-blog/php/202006/source/PHPDebug互动扩展.php]

[L14         0x109eef720 ECHO                    "\n"                                                           /Users/zhangyue/MyDoc/博客文章/dev-blog/php/202006/source/PHPDebug互动扩展.php]

 

[L15         0x109eef740 EXT_STMT                                                                               /Users/zhangyue/MyDoc/博客文章/dev-blog/php/202006/source/PHPDebug互动扩展.php]

>00015: }

 00016:

 00017: testFunc();

以上就是php方法断点的实现,大家学会后也赶快尝试下实例操作吧。更多php学习指路:php教程

推荐操作系统:windows7系统、PHP5.6、DELL G3电脑

以上是 php方法断点如何实现 的全部内容, 来源链接: utcz.com/z/544911.html

回到顶部