note 128047 added to function.phpdbg-break-file
| From: | JeffB dot Carter at main dot php dot net | Date: | Fri, 23 Dec 2022 15:34:45 +0000 |
| Subject: | note 128047 added to function.phpdbg-break-file | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-220003@lists.php.net to get a copy of this message | ||
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]
----
Server IP: 45.112.84.4
Probable Submitter: 185.85.3.175 (proxied: 2600:1700:3c53:a090:a42c:c9eb:80d:dcf9)
----
Manual Page -- https://php.net/manual/en/function.phpdbg-break-file.php
Edit -- https://main.php.net/note/edit/128047
Del: integrated -- https://main.php.net/note/delete/128047/integrated
Del: useless -- https://main.php.net/note/delete/128047/useless
Del: bad code -- https://main.php.net/note/delete/128047/bad+code
Del: spam -- https://main.php.net/note/delete/128047/spam
Del: non-english -- https://main.php.net/note/delete/128047/non-english
Del: in docs -- https://main.php.net/note/delete/128047/in+docs
Del: other reasons-- https://main.php.net/note/delete/128047
Reject -- https://main.php.net/note/reject/128047
Search -- https://main.php.net/manage/user-notes.php