1

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); } 

1 Answer 1

3

In Craft 3 it is actually possible.

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

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

2
  • 1
    My god... what have I done? :) Commented Jan 17, 2019 at 15:37
  • Only because you can, doesn't mean you should :) Commented Jan 18, 2019 at 10:20

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.