PHPS stands for PHP Source. If you encounter a PHP script whose functionality you have a particular interest, you usually take the regular file extension of .php, .php3, or .phtml, and add an 's'. Doing so will present you with a regular HTML file giving you a nice color-coded view of the source. This is only however, if the webmaster/administrator has set up the option, as it is not active by default.

If PHP has been installed as an Apache module as is recommended for speed, then you can simply add this line to .htaccess:

AddType application/x-httpd-php-source .phps

Now, if you use other file extensions for your PHP scripted files, you can use those as well, ie:

AddType application/x-httpd-php-source .phps .phtml .php3

By looking at the simple setup of the .htaccess, you can see that you don't have to take the regular file extension and add an 's', that is just the standard practice. You could use '.x' or '.secret' or, logically '.source', it is your choice!

If you chose (or where forced to) install PHP as a CGI binary, then you have to take a slightly roundabout way. You use a regular PHP file, containing the line:

<?php show_source ("$File"); ?>

You can either have $File hardcoded, or set it in the URL, ie:

Or do both! Like I do on my frames enabled index page.

	if (isset($GoTo)){
		echo "<FRAME SRC=\"$GoTo\" NAME=\"Content\">";
		echo "<FRAME SRC=\"news/current.phtml\" NAME=\"Content\">";

If you know PHP, than you should see how the above example applies even though it is in a different context than giving show_source() a filename.

Please note that using the show_source() function presents some security issues, as a visitor could set $File to anything. The function will delve right into protected directories if Apache/PHP has access to them and a user sets $File. I don't think it checks filetypes either, an unfriendly visitor might get show_source() to dump lots of color coded stuff besides PHP source, such as .htpasswd, or more!

Log in or register to write something here or to contact authors.