Can I use the ".phps" file type to view highlighted PHP source code?

Some Web servers allow you to name a file so that it ends with ".phps", then see a color-coded version of the PHP source code when you view the file in a Web browser. For that feature to work automatically, the server must run PHP as a "module", which we don't do for security reasons.

However, advanced users can easily get the same functionality. You have to add a simple PHP file to your site, then add two lines to your .htaccess file.

To do this, first create a new PHP file named "phps.php" at the top level of your website that contains these lines:


Then add these two lines to your ".htaccess" file:

AddHandler application/x-httpd-php-source .phps
Action application/x-httpd-php-source /phps.php

That's all it takes: from then on, any file ending in ".phps" will be displayed and highlighted.