Watching our Script Run
Prev | Debugging a Project Locally Using PHPEclipse and XDebug | Next

## Watching our Script Run

Now that we are familiar with the Debug Perspective, we can trace the execution of our program and monitor the variables. We will do a click by click run through of a few lines of our program. To trace through execution of the loop, click on the 'Step Into' button.

1. In our initial state, you will see that the blue arrow points to the first line of our script. This line initializes the $output variable. Since the line hasn't been executed yet, you will see both $i and $output are unitialized.

2. After one click of the Step Into button, the blue arrow moves to the first line of our for loop. Again, this line has not been executed, so $i is still uninitialized, but $output has now been initialized to ''.

3. After two more clicks, we are into our for loop. The Variables window tells us that $i is 0 and $output is still ''.

4. After another click, $output has been assigned the value 'Loop0'.

5. After another click, $i is incremented and now has the value 1. The console displays the output 'Loop0', which is the result of the echo statement. The blue arrow has returned to the top line of the for loop, ready for another iteration.

By continuing in this manner, we can see the values of each variable as execution of our script progresses and we can monitor the output after each line of the script..

Prev | Up | Next
Adding a Breakpoint | Home | Conclusion