Re: showing source
| From: | itoctopus | Date: | Fri, 18 May 2007 10:34:23 +0000 |
| Subject: | Re: showing source | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-255118@lists.php.net to get a copy of this message | ||
yup, highlight_file($file_name) is your magical answer.
http://ca.php.net/highlight_file
Make sure this function will only access specific directories.
--
itoctopus - http://www.itoctopus.com
""M.Sokolewicz"" <tularis@php.net> wrote in message
news:464D716B.7040702@php.net...
> Why don't you use:
> highlight_file(__FILE__) ?
>
> - tul
>
> James Lockie wrote:
>> This almost works but all my < and > are replaced with "".
>>
>> // open this file to show the source
>> if (($fh = fopen( __FILE__, 'r' )) === FALSE){
>> die ('Failed to open source file (' . $_FILE_ . ') for
>> reading!');
>> } else {
>> $tags = array( "<", ">" );
>> $safe_tags = array( "\\<", "\\>" );
>>
>> print "<pre>\n";
>>
>> // read the file line by line
>> while (! feof( $fh )) {
>> $currentLine = fgets( $fh, 255 );
>> $noTags = str_replace( $tags, $safeTags, $currentLine );
>> print $noTags;
>> }
>>
>> fclose( $fh );
>> print "</pre>\n";
>> }