phpdbg_break_file
(PHP 5 >= 5.6.3, PHP 7, PHP 8)
phpdbg_break_file — Inserts a breakpoint at a line in a file
说明
Insert a breakpoint at the given line
in the given
file
.
参数
file
-
The name of the file.
line
-
The line number.
返回值
没有返回值。
参见
- phpdbg_break_function() - Inserts a breakpoint at entry to a function
- phpdbg_break_method() - Inserts a breakpoint at entry to a method
- phpdbg_break_next() - Inserts a breakpoint at the next opcode
- phpdbg_clear() - Clears all breakpoints
+添加备注
用户贡献的备注 1 note
Jeff B. Carter ¶
2 years ago
Here is an example of how to programmatically add a breakpoint based on a condition:
<?php
$blah = 'meh';
if ($blah !== 'blah') {
phpdbg_break_file('blah.php', 6);
}
$blah = 'blah';
echo $blah;
?>
OUTPUT when running the debugger (using ev to evaluate the value of $blah after each step):
C:\path\to\dir>phpdbg -e blah.php
[Welcome to phpdbg, the interactive PHP debugger, v8.1.6]
To get help using phpdbg type "help" and press enter
[Please report bugs to <http://bugs.php.net/report.php>]
[Successful compilation of C:\path\to\dir\blah.php]
prompt> run
[Breakpoint #0 added at C:\path\to\dir\blah.php:6]
[Breakpoint #0 at C:\path\to\dir\blah.php:6, hits: 1]
>00006: $blah = 'blah';
00007: echo $blah;
00008: ?>
prompt> ev $blah
meh
prompt> step
>00007: echo $blah;
00008: ?>
prompt> ev $blah
blah
prompt> step
blah>00008: ?>
prompt> step
[Script ended normally]
备份地址:http://www.lvesu.com/blog/php/function.phpdbg-break-file.php