How to debug Loops?
This is my code, and I want to debug this for loop, so I will know how this loops works in each step, how can I do that with phpstorm?
<?php
for ($i = 0; $i <= 5; $i++){
for ($j = 5-$i; $j>=1; $j--){
echo "* ";
}
echo "<br>";
Please sign in to leave a comment.
Hi there,
I'm really sorry .. but I do not understand what kind of problem you are having here (I mean -- what part of the debugging process you are having problems with?).
If you are not familiar with debugging procedures in PhpStorm -- here are few links:
Why the step option is not active here
Based on your screenshot ... because you are not debugging it yet .. or debug run already finished without stopping at breakpoint (or alike)..? I cannot say for sure without seeing whole procedure that you did that end up with this screenshot.
Then definitely I am doing wrong, I just click on the code to get that debug red line, that's it.
Well .. you have to at least execute this script in debug mode to have debug working. For that, of course, you need to have local PHP with xdebug (or Zend Debugger) installed and configured properly.
Have a look at my first link again -- it has almost 1 hour long video that shows the PHP debugging process for various scenarios (plus articles for other cases/how to set it up/etc.). You may also just search "phpstorm debug" on youtube and you will get few tutorials done by different people there.
Also:
Maybe this one would help?
Finally after the whole day, xdebug was installed, now when I am trying to debug the code, it is showing
Kindly help.