PHP eval filter for Twig If I am confident in the users of our webpage that they will never be messing with the Twig templates, then what risk is there to creating a |php filter for Twig that just does this? 

{% set text = "echo 'Hello World';" %) 
{{ text | php }} 


Filter function:

function myPhpEvalFunction ($text = null) {
   return eval($text);
}
In Craft 3 it is actually possible.

{{ craft.app.view.evaluateDynamicContent('phpinfo();') }}


See: Can we use PHP in our templates instead of Twig?