I was trying to make an HTML editor for my webpage in PHP. First I had to make a script to display what is in the HTML documents, and in doing so, I encountered a problem.
Whenever I use fgets() to read a line out of any document with >'s or <'s, it just doesn't display anything.
And since HTML is obviously going to have a lot of <'s or >'s, this makes it hard to view and edit HTML files.
Do I need another function to read and write in files with these signs or is there some other way to use fgets()?
Here's a little bit of the code I was using. Maybe it's my fault it's not working? ???
<html><body>
<?php
$here = "makey-makey, eggs and bakey";
$filename = $_POST["filename"];
$fr = fopen($filename, 'r');
if(!$fr) {
fclose($fr);
$fr = fopen($filename,'w');
if(!$fr) {
echo "Could not create the counter file!";
exit;
}
fputs($fr, $here);
fclose($fr);
} else {
$line = fgets($fr, 1024);
echo $line;
fclose($fr);
}
?>
</body></html>