note 40751 deleted from function.show-source by aidan

From: Date: Sun, 26 Sep 2004 14:10:44 +0000
Subject: note 40751 deleted from function.show-source by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-77393@lists.php.net to get a copy of this message
Note Submitter: sysop at NOSPAM dot accessdeniedbbs dot net ---- <?php /* Function to show source of file with padded line numbers. Presented in a formatted layout with ability to enable/disable word wrapping. If file does not exist, the user is informed. Usage: void ShowSource(string filename [, boolean|string wordwrap]) Example output: Source File: HelloWorld.php (3 lines) 00001 <?php 00002 print "Hello World!"; 00003 ?> */ // Example of calling the function to show the source // for HelloWorld.php with word wrap disabled... ShowSource("HelloWorld.php",true); /* The function... */ function ShowSource ($filename="",$wrap=true) { if (file_exists($filename)) { ob_start(); show_source( $filename ); $t = ob_get_contents(); ob_end_clean(); $source=explode("<br />",$t); $counter=1; if ($wrap==false) $wrap=" nowrap='nowrap'"; else $wrap=""; print "Source File: $filename (".count($source)." lines)<br /><br />"; print "<table cellspacing='2' cellpadding='0'>"; foreach ($source as $line) { print "<tr><td bgcolor='silver'>".sprintf("%05d",$counter++)."</td>"; print "<td$wrap>$line</td></tr>\n"; } print "</table>"; } else print "Sorry, $filename was not located on this server...<br />"; } ?>

« previous php.notes (#77393) next »