I want to do some basic debugging with print_r.
When PHP hits that line I want it to stop or end whatever people usually do, so I can see the output.
// if you want a one liner:
die(print_r($stuff, true ));
You'd really enjoy a proper debugger though
For stopping execution in PHP, you have for example die and exit.
For advanced debugging, use tools such as XDebug.
Or sleep: sleep(30);
for a 30 second delay.
Here:
print_r($whatever);
exit();
die("Script Stopped");
This will end execution of code and echo the message you put between the quotations - this can be a string or an integer you need to debug, I use it often when debugging. Half-split works well, put var_dumps halfway through your code, put a die at the end, find which half is going wrong, split that in half, etc, until you get to a point that you can logically guess where the error is and start debugging the syntax/etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With