note 14369 added to function.show-source.php
| From: | dava at mail dot dk | Date: | Sat, 28 Jul 2001 01:26:42 +0000 |
| Subject: | note 14369 added to function.show-source.php | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-15963@lists.php.net to get a copy of this message | ||
While I'm still new at PHP I often need to display my code to my online buddies helping me out
with the scripts, however, they often need to see the included scripts as well, so here's a
little piece of code formatting the include() entries to a show-source link:
First output the source to a string:
ob_start();
show_source ($page);
$page_text = ob_get_contents();
ob_end_clean();
Now format and output the source:
$page_text = explode ("\r", $page_text);
for ( $q = 0; $q < count ($page_text); $q++) {
if (ereg ("inc\..*\.php", $page_text[$q], $inc_file)) {
$inc_link = "<A HREF=\". $PHP_SELF ."?page=". $inc_file[0]
."\">". $inc_file[0] ."</A>";
echo ereg_replace ("inc\..*\.php", $inc_link, $page_text[$q]);
} else {
echo $page_text[$q];
}
}
Note: No security are NOT built into the above code.
Hope this is of use to anyone :)
http://www.php.net/manual/en/function.show-source.php