PHP micro-script displays PHP, HTML, Javascript code without parsingMay 6, 2006 It's almost embarrassing to release code this miniscule, but I haven't found anything similar anywhere else on the 'Net. It displays PHP, HTML, Javascript and other source code direct from file, unparsed, and presents it cleanly and professionally. An image link brands the displayed code, and refers viewers back to the main site. To use, call source.php with the name of the file to display, i.e. source.php?file=source.php Code can be saved directly, or copied and pasted, without problems. Complete functionality derives from one simple PHP function - htmlentities(): echo '<pre
style="background-color:#FFF3CC;padding:10px;padding-top:50px">'.
htmlentities(@file_get_contents($f)).'</pre>'; The htmlentities() function converts all PHP, HTML and other tags to non-coding, display-only character codes, without parsing. Too easy. This PHP script is released under the terms of the GNU General Public License, i.e. free for you to use, modify, and even redistribute under the terms of this license - see http://www.gnu.org/copyleft/gpl.html for further details. Full source.php code is presented here by source.php itself (in an odd sort of homage to PHP - the acronym is self-referential). More on PHP and the htmlentities() function at http://php.net/. download source.zip - PHP code and documentation
|