track7
sign in
sign in securely with your account from one of these sites:
note:  this is only for users who have already set up a password.

show php source

snippet

this script gives you an easy way to allow visitors to view your php source code. it uses php’s highlighting functions to color the php code for easier reading, and limits visitors to viewing source of files with the php extension inside the document root (usually public_html). note that if you have sensitive information such as sql passwords in a php file you should be sure that it is outside document root, or modify the show source script to explicitly exclude that file.

files

download

requirements

instructions

the zip file contains 3 files: a php script, a css file, and an .htaccess file. the .htaccess file is not required, but can be added to your .htaccess file so that /source/index.php will show the source of index.php. if this is done, you can use the following php code to make a link to the source of the current page:

<a href="/source<?php echo $_SERVER['PHP_SELF']; ?>">view php source</a>

if the .htaccess file is not used, change /source to /showsource.php?file= for the same result. the php file references the css file. all files are expected to be in the document root (i.e. http://www.example.org/showsource.css) and use the filenames they have in the zip file. if you move or rename the files, you will have to update the other files so they know where to find each other.

comments

{{error}}

there are no comments on this script so far. you could be the first!

{{comment.name}}
posted