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?



for ($i = 0; $i <= 5; $i++){
for ($j = 5-$i; $j>=1; $j--){
echo "*&nbsp";
echo "<br>";



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?).


  • You just place breakpoint on first loop and then use "Step Over" or "Step Into" (both will do the same in this simple code where no user functions get called) to move to next execution line/instruction.
  • If you are debugging CLI script (Run/Debug Configuration of "PHP Script" type) then output will be located in "Console" tab. For web scripts -- output will be sent to a browser when buffer is full (depends on your web server/php config).
  • All variables can be watched live in "Variables" tab; With "Show values inline" option enabled (should be by default) values will also be displayed in editor itself

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.



Finally after the whole day, xdebug was installed, now when I am trying to debug the code, it is showing

Kindly help.


Please sign in to leave a comment.