Community Documentation

About enabling PHP code in posts

Last updated April 22, 2010. Created by keith.smith on December 7, 2007.
Edited by LeeHunter, AjK, webchick. Log in to edit this page.

The PHP filter core module adds the ability to include PHP code in posts. PHP is a general-purpose scripting language widely-used for web development; the content management system used by this website has been developed using PHP.

Through the PHP filter, users with the proper permission may include custom PHP code within a page of the site. While this is a powerful and flexible feature if used by a trusted user with PHP experience, it is a significant and dangerous security risk in the hands of a malicious user. Even a trusted user may accidentally compromise the site by entering malformed or incorrect PHP code. Only the most trusted users should be granted permission to use the PHP filter, and all PHP code added through the PHP filter should be carefully examined before use.

Some example PHP snippets are available, or you can create your own with some PHP experience and knowledge of the Drupal system.

About this page

Drupal version
Drupal 6.x, Drupal 7.x
Drupal’s online documentation is © 2000-2013 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License. Comments on documentation pages are used to improve content and then deleted.