[thelist] HOWTO read PHP source code into a textarea

Michael Pemberton evolt at mpember.net.au
Thu Feb 24 18:46:03 CST 2005


Tim Burgan wrote:
> Hello,
> 
> 
> I have a file 'nav.php', whose source code I want to load into the 
> textarea on page 'aaa.php', so the source can be edited and changed.
> 
> Is there a resource that I can read to help me do this?
> 
> 
> Thanks
> 
> Tim
> 
> 

I am resisting opening my email with those lovely letters that should be 
written on the outside of every piece of equiptment in the house, "RTFM" :)

The PHP manual has an example that does exactly what you want.

<quote src="PHP Manual">

<?php
$html = implode('', file('http://www.example.com/'));
?>

</quote>

The code you would need is something like this:

<textarea>
<?php
echo implode('', file('nav.php'));
?>
</textarea>

This is just a quick example, you can throw in some error checking and 
such stuff yourself.

hth
-- 
Michael Pemberton
evolt at mpember.net.au




More information about the thelist mailing list