Drupal: Write & Execute PHP code in blog post/forum content entry

This is a short but efficient trick that I found after making some stupid search queries 😦 In Drupal 6 & higher, you can type & execute PHP codes in your blog posts/ other contents. To do so, First enable the PHP Filter module from your Adminstration > Modules section:

(drupal-path/admin/build/modules)
php filter module
Enabling the PHP Filter module

Next, you can configure who must have access to execute PHP in their content. To grant only trusted users this permission, go to the Input Formats section (available under Administer » Site configuration)

(drupal-path/admin/settings/filters)

Next, click on “configure” link next to the php code box.

How to write php in your posts

When creating a new blog/other entry, click on the “Input Format” just below the text editor. From the available options, select php code. See the screenshot below:

php in drupal

Hope this will be helpful!