On this page:
- Evaluating Arbitrary Expressions
- Evaluating Expressions in the Editor
- Evaluating Variables in the Console Pane
PhpStorm enables you to evaluate arbitrary single-line expressions and provides a way to quickly evaluate an expression in the editor at caret or a selection.
While using the Expression Evaluation feature, be aware of the following:
- A method can be invoked within the Expression Evaluation dialog only if the debugger has stopped at a breakpoint, but has not been paused.
- Expression Evaluation can only be "single-level". In other words, if PhpStorm stops at a breakpoint within a method called from the Expression Evaluation, you cannot use the Expression Evaluation feature again.
Evaluating Arbitrary Expressions
- Open the Evaluate Expression dialog box in one of the following ways:
- Choose on the main menu.
- To evaluate a specific variable, select it on the Variables pane of the Debug tool window, then choose or press Alt+F8.
- In the
dialog box, specify the expression you want to evaluate. Do one of the following:
- In the Expression field, type the expression in question or choose one of the
previously evaluated expressions from the drop-down list.
If you have selected a specific variable on the Variables pane, this variable will be displayed in the Expression text box.
- To evaluate a code fragment, click the Code Fragment Mode button and
fill in the Code Fragment text box.
To return to the original mode, click the Expression mode button.
- In the Expression field, type the expression in question or choose one of the previously evaluated expressions from the drop-down list.
- Click the Evaluate button. The Result read-only field shows the evaluation output. If the specified expression cannot be evaluated, the Result field explains the reason.
Evaluating Expressions in the Editor
During a debugger session, the value of any expression is shown in the tooltip every time you hover your mouse pointer over it. If an expression contains children, clicking expands the node and displays all children.
You can also use the Quick Evaluate expression functionality that lets you view the value of an expression using the keyboard only.
There are two ways to evaluate an expression quickly:
By using the Show value tooltip on code selection functionality:
- In the Debugger | Data Views settings page, enable the Show value tooltip on code selection option.
Select a code fragment with the mouse, or by clicking
Ctrl+W. A tooltip with the expression value automatically appears under the selection and changes each time you change the selection:
- By manually invoking the tooltip with the expression value:
Evaluating Variables in the Console Pane
This can be done in several ways:
- Select the variable in question in the Variables pane and choose
Evaluate in Console on the context menu of the selection.
When you switch to the Console pane, the variable name is shown as input (
<) and its value is marked with
- Alternatively you can type the name of any variable in the Console manually and press Enter to have its value displayed.
- To evaluate a previously evaluated variable without searching for it in the Variables pane, find the variable in question using the Up and Down arrows on you keyboard and press Enter.