0

hi,
I'm doing a web that can show html file code into textarea using php but my problem is when reading a html file that also contain textarea

this is my html

<html>
<body>
<textarea>
Trying this !!!!!!!!
</textarea>
<br>
<span>ASD</span>
</body>
</html>

and this is my php code that can read html file

<html>
<body>
<textarea>
<?php

$myFile = 'try.html';
$content = file_get_contents($myFile);
if ($content !== false) {
   echo $content;
} else {
   // an error happened
}

?>
</textarea><br>
<input onClick="save()" id="x" type="button" value="Save"><br><br>
</body>
</html>

and the result is my html <span>ASD</span> is show outsite my php textarea because in html contain </textarea> that close my <textarea> in my php

for more clear what I mean this is the screenshot
http://s12.postimage.org/z76e4jjct/screenshot1.jpg

please help me how to make that my html source not interfere with my php code

2
Contributors
1
Reply
26
Views
4 Years
Discussion Span
Last Post by broj1
1

Try using htmlspecialchars function which will replace < and > with their html codes.

if ($content !== false) {
    echo htmlspecialchars($content);
}

Edited by broj1

Votes + Comments
thanks its work
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.