astralaaron Posted February 13, 2010 Share Posted February 13, 2010 I am having a small problem. my little program loads the contents of other files in the same directory into textareas where you can make changes to the code.the problem I am having, is if there is a <textarea></textarea> inside of the file, it is ending the textarea short, and writing the rest of the code all over my page.anyone have any ideas for a solution?EDIT***I just tried this with no success:$file = $_GET['file']; $fh = file($file); $content = ""; foreach($fh as $line => $value) { str_replace("</textarea>","[/TA]",$value); $content.=$value; }echo $content;still no luck, I was trying to convert to [/TA] then I was going to convert it back when you save..help please :)EDIT AGAIN*** $content.= str_replace("</textarea>","[/TA]",$value);this looks like it will work, nevermind Link to comment Share on other sites More sharing options...
jeffman Posted February 13, 2010 Share Posted February 13, 2010 The browser is reading the closing tag of the internal textarea as the closing tag to the outer one.Sounds like you want to be able to edit HTML?The only real bad character here is the < character. You could replace that with its < entity. Or just run the whole file contents string through htmlspecialchars, which does that to the < and several others too. Link to comment Share on other sites More sharing options...
astralaaron Posted February 13, 2010 Author Share Posted February 13, 2010 The browser is reading the closing tag of the internal textarea as the closing tag to the outer one.Sounds like you want to be able to edit HTML?The only real bad character here is the < character. You could replace that with its < entity. Or just run the whole file contents string through htmlspecialchars, which does that to the < and several others too.none of the other <'s cause any problems, only the </textarea>I made it replace the </textarea> then replace it back and now it works fine.. Link to comment Share on other sites More sharing options...
boen_robot Posted February 14, 2010 Share Posted February 14, 2010 It will be much easier if you use htmlspecialchars() on the content, like for example: <textarea><?php echo htmlspecialchars(file_get_contents($_GET['file'])) ?></textarea> AFAIK, you don't need to do anything special upon submitting in that case. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.