x
 
Create New Page
 View Previous Changes    ( Last updated by Lisa Wess )

PHP In Entries

If you follow the instructions below, you’ll be able to use raw PHP inside your entries, which will be processed like regular PHP, alongside regular entry text (which will stay as regular entry text). This is very powerful, so use it at your own risk!

You’ll need the following plugins:

* Allow EE Code
* Allow PHP

Instructions

1. Install the plugins by putting them inside your system/plugins folder.

2. Set text formatting for the field you want to use this on to “None” (Admin > Weblog Administration > Custom Weblog Fields).

3. Change your template by adding the Allow EE tags around the field you are using this on:

{exp:allow_eecode}{body}{/exp:allow_eecode}

4. Now you can use PHP inside your entries like this:

<p>Bla bla regular entry text</p>

{exp:allowphp}
echo "This will be processed as PHP.";
{/exp:allowphp}

Without exp:allow-eecode

If your entries do not need to process EE code but do need to process PHP, then you can just put the exp:allowphp tags right into the template, bypassing the allow_eecode plugin. In your template, simply put:

{exp:allowphp}
{body}
{
/exp:allowphp}

Then place the code into the field (set as above) without the opening and closing PHP tags. (No <?php or ?>) Using the example above, all that would go into {body} would be:

echo "This will be processed as PHP.";

Category:PHP Category:Tips Category:Tricks Category:Templates

Categories: