The documentation says:

Snippets are expanded at a very early stage on each template, making it possible for them to hold dynamic content, ExpressionEngine tags, other variables, PHP, etc.

The evidence seems to run contrary to that statement.

Can PHP be used in a snippet as it can in an embed when enabled?

The scenario: I have Google Analytics and other tracking code in a snippet. I want to wrap it in a simple PHP conditional to check for the live site URL, so I'm not hitting that code in my development/staging environment.



1 Answer 1


Yes, as long as the template in which you put the snippet has PHP enabled.

  • Ah, the template that the snippet is rendered via, because the snippet is just merged in. Got it. As this is a snippet on every page, I'm better off with an embed if I want to do that. Thanks! Commented May 29, 2013 at 21:01
  • @low:can you please give me the syntax of including a snippet in my template?EE docs have only docs showing only embed syntax
    – user2133
    Commented Feb 21, 2014 at 7:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.