Jump to main content Jump to doc navigation
Note: The @EVAL binding has been deprecated and removed in MODX 3.0.

What is the @EVAL Binding?

The @EVAL Binding executes the specified PHP code. It should be used with careful security precautions.


@EVAL php_code_here


Simply put a PHP statement after the @EVAL tag:

@EVAL return "The time stamp is now ".time();
@EVAL $a = 'dog'; return $a;


There's a whole page showing an example of using the EVAL binding to execute a snippet: Creating a multi-select box for related pages in your template.

db-driven input-option-values by using rowboat

Let's say we want to have a dropdown-box to select a user-id by username. Requirements: The rowboat-snippet.

First, we create a new chunk for our Options and name it 'userOption' with this code:


Then create a dropdown-type TV with this input-options:

@EVAL return '-- choose a user --||' . $modx->runSnippet('Rowboat',array('table'=>'modx_users','tpl'=>'userOption','outputSeparator'=>'||'));


The use of eval() is a security sensitive binding and should be used with caution. For this reason it has also been removed in 3.0 and can be disabled sooner with the allow_tv_eval system setting.

See Also

Support the team building MODX with a monthly donation.

The budget raised through OpenCollective is transparent, including payouts, and any contributor can apply to be paid for their work on MODX.



$0 per month—let's make that $500!

Learn more