note 14369 deleted from function.show-source by jimw
| From: | jimw@php.net | Date: | Fri, 07 Dec 2001 02:31:52 +0000 |
| Subject: | note 14369 deleted from function.show-source by jimw | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-21836@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 :)