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

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

if ($content !== false) {
    echo htmlspecialchars($content);
}
commented: thanks its work +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.