Inspecting Data in the Debugger
While your PHP code is broken in the debugger, you can view the contents of local and global variables using DataTips, the Watch windows or the immediate window. You can also change values of the variables, or evaluate expressions.
To view a value using DataTip, simply hover the mouse over any variable in the editor.
Note: DataTips are always evaluated in the context where execution is suspended, and not where the cursor is hovering. If you hover over a variable in another function with the same name as a variable that is in the current context, the value of the variable in the other function is displayed as the value of the variable in the current context.
While debugging, you can examine and evaluate variables and expressions using the Watch windows. It also allows expanding objects and arrays to see their members by clicking the
> expansion indicator.
Watch windows also allows you to edit the value of a variables in the current debugging session. For instructions, see How to: Edit a Value in a Variable Window.
You can set the numeric format used in the debugger windows to decimal or hexadecimal by right-clicking the Watch window and choosing the Hexadecimal Display option from the context menu.
The Locals window (
Debug | Windows | Locals) contains all variables that are in the current scope.
Superglobals object always present in the Locals window. This is just a helper which contains all Superglobal variables, whicht are built-in variables that are always available in all scopes. More about superglobals in PHP manual.
The Autos window (
Debug | Windows | Autos) displays variables in the current statement and three statements on either side of the current statement.
The current statement is the statement at the current execution location (the statement that will be executed next if execution continues). The debugger identifies these variables for you automatically, hence the window name.
The Watch windows (
Debug | Windows | Watch | Watch 1-4) allow you to enter arbitrary PHP expressions and view the results.
These expressions are reevaluated for each step, unless PHP Tools decides they might cause side efects. A side effect occurs when evaluating an expression changes the value of data in your application. In this case reevaluation of this expression is postponed and only happens when explicitly triggered by user.
Note: Expressions are always evaluated against top stack frame. On the other hand, if you are simply inspecting variable value, the value is returned from the current frame on the stack. You can always change the current frame in the Call Stack window.
The QuickWatch dialog box lets you examine and evaluate variables and expressions. Because QuickWatch is a modal dialog box, you have to close it before you can continue to debug.
The QuickWatch dialog can be useful if you just want to do a quick scratch calculation that involves one or more variables and you do not want to clutter the Watch window with such calculations. For this reason you can also use Immediate Window.
When a value being inspected is a string, you will see a magnifying glass icon on the right side of the value. Clicking on it will display the unquoted string value in a popup dialog, with wrapping and scrolling, which is useful for long strings. In addition, clicking on the drop-down arrow on the icon will allow you to select the visualization mode that you want to use: plain text, HTML, XML, and JSON.
In HTML mode, an embedded browser instance will be used to render the HTML code in the string. In XML and JSON modes, there is syntax highlighting for the corresponding markup, and you can expand and collapse individual nodes in the tree.
The Immediate window (
Debug | Windows | Immediate) evaluates entered expressions which are evaluated against the top stack frame and results are printed.
Note: Changing current frame in the Call Stack window will only affect simple variable inspections, expressions evaluation will not work.