[thelist] Edit textfiles in textareas?

Simon Willison cs1spw at bath.ac.uk
Sat Sep 27 07:08:04 CDT 2003


Ken Moore wrote:
> That was close enough to help. The exact code is:
> 
> <textarea><?php echo $file_contents ?></textarea>

In fact, that could lead to problems if the text file you are editing 
contains HTML - in particular a </textarea> tag. To avoid those 
problems, do this:

<textarea><?php echo htmlspecialchars($file_contents); ?></textarea>

Cheers,

Simon
http://simon.incutio.com/



More information about the thelist mailing list