How to insert and use the PHP Snippets in your pages
Last modified: July 2, 2005 - 08:16
The PHP SNIPPETS come with a brief introduction on what it does and if it only works with specific versions of Drupal.
Some are very similar to how you SETUP CUSTOM BLOCKS WITH CONTENT THAT APPEAR IN THE SIDEBARS but the snippets below are intended for use within your main NODE page as opposed to your sidebars.
Once you get used to how the PHP Snippets work and if you are familiar with how to setup up a HTML table or using DIVs, you can mix snippets together in the same page creating sophisticated layouts like those found at http://www.mtv.com or http://www.yahoo.com.
- Go to CREATE CONTENT -->> PAGE
- Give your page a TITLE
- In the BODY text area, paste in your PHP Snippet. Make sure you include the opening and closing PHP statements and remove any extra spaces, line breaks after the final
?>which tells drupal that this is the end of the php page. - Select the PHP CODE filter.
- Click SUBMIT or PREVIEW to view your page.

First you must enable "PHP filter" module
To accomplish Step 4, first you must enable "PHP filter" module in Administer/Modules section.
doesn't work
I enabled the PHP filter from the module section even after when i put the php code snippet in my page body it just display the code as it is .. Iam using drupal 6.10. What could be the problem?..
thank you..
try this
You actually enter the php as text that's why it displays the code itself. Follow this to solve, enable FCKeditor if you haven't, click tab "Source" on the first row of FCKeditor tool bar, paste the php code there, that means php code should be on source code interface not text interface. Finally save the change. It should solve the problem.
PHP Code Snippet Not Executing in Page HTML
I am running into the same problem attempting to run an embedded php snippet, even after enabling the PHP Filter Module.
Input Format
After doing so, you must go to Administer > Site config > Input formats, enter on formats that you wanna let PHP be used and chech "PHP evaluator".
GRRRR php vanishes after I save my page
wow, well this is somewhat confusing. I just spent about 10 minutes writing my code and inserting my custom functions into the page. As soon as I saved the page, my code did not work and drupal does not preserve the php script in my page. It seems like it sends the php to cache and only shows me the html output.
How can i preserve the php in the body?