Printing PHP Source with a PHP Script

This is a discussion on Printing PHP Source with a PHP Script within the PHP General forums, part of the PHP Programming Forums category; Hi everyone, I'm trying to output PHP source within a PHP Script. The following script seems to work(Viewing ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 12-15-2003
Gohaku
 
Posts: n/a
Default Printing PHP Source with a PHP Script

Hi everyone,
I'm trying to output PHP source within a PHP Script. The following
script seems to work(Viewing HTML Source reveals the PHP Source), but
the Browser output is very different. Is there a function or header I
should set before echoing the PHP Source? Thanks.


<?
//filereader.php
//script arguments: filereader.php?file=
$fh = fopen($file,"rb");
$src = fread($fh,filesize($file));
fclose($fh);
echo '<html><meta http-equiv="Content-Type" content="text/plain">';
echo $src;
echo '</html>';
?>
Reply With Quote
  #2 (permalink)  
Old 12-15-2003
John W. Holmes
 
Posts: n/a
Default Re: [PHP] Printing PHP Source with a PHP Script

Gohaku wrote:

> Hi everyone,
> I'm trying to output PHP source within a PHP Script. The following
> script seems to work(Viewing HTML Source reveals the PHP Source), but
> the Browser output is very different. Is there a function or header I
> should set before echoing the PHP Source? Thanks.
>
>
> <?
> //filereader.php
> //script arguments: filereader.php?file=
> $fh = fopen($file,"rb");
> $src = fread($fh,filesize($file));
> fclose($fh);
> echo '<html><meta http-equiv="Content-Type" content="text/plain">';
> echo $src;
> echo '</html>';
> ?>
>


echo htmlentities($src);

--
---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com



Reply With Quote
  #3 (permalink)  
Old 12-15-2003
Mike
 
Posts: n/a
Default Re: [PHP] Printing PHP Source with a PHP Script

John W. Holmes wrote:
> Gohaku wrote:
>
>> Hi everyone,
>> I'm trying to output PHP source within a PHP Script. The following
>> script seems to work(Viewing HTML Source reveals the PHP Source), but
>> the Browser output is very different. Is there a function or header I
>> should set before echoing the PHP Source? Thanks.
>>
>>
>> <?
>> //filereader.php
>> //script arguments: filereader.php?file=
>> $fh = fopen($file,"rb");
>> $src = fread($fh,filesize($file));
>> fclose($fh);
>> echo '<html><meta http-equiv="Content-Type" content="text/plain">';
>> echo $src;
>> echo '</html>';
>> ?>
>>

>
> echo htmlentities($src);
>


there is a function just for this

highlight_file($file);

is all you need

Mike
Reply With Quote
  #4 (permalink)  
Old 12-15-2003
Gohaku
 
Posts: n/a
Default Re: [PHP] Printing PHP Source with a PHP Script


On Sunday, December 14, 2003, at 09:51 PM, John W. Holmes wrote:

> Gohaku wrote:
>
>> Hi everyone,
>> I'm trying to output PHP source within a PHP Script. The following
>> script seems to work(Viewing HTML Source reveals the PHP Source), but
>> the Browser output is very different. Is there a function or header
>> I should set before echoing the PHP Source? Thanks.
>> <?
>> //filereader.php
>> //script arguments: filereader.php?file=
>> $fh = fopen($file,"rb");
>> $src = fread($fh,filesize($file));
>> fclose($fh);
>> echo '<html><meta http-equiv="Content-Type" content="text/plain">';
>> echo $src;
>> echo '</html>';
>> ?>

>
> echo htmlentities($src);
>


Thank you, that's just what I was looking for.
> --
> ---John Holmes...
>
> Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
>
> php|architect: The Magazine for PHP Professionals – www.phparch.com
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 01:53 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0