KingOfHeart Posted April 15, 2010 Share Posted April 15, 2010 if(file_exists($file)) { $fh = fopen($file, 'r'); $fr = fread($fh, 1024); fclose($fh); echo $fr; return; } This doesn't seem to work on php files. I'm assuming it's because of all the HTML and php data. How do I just print everything as text? Link to comment https://forums.phpfreaks.com/topic/198681-reading-and-outputting-file-data/ Share on other sites More sharing options...
teamatomic Posted April 15, 2010 Share Posted April 15, 2010 $fr=htmlentities($fr); echo $fr; HTH teamatomic Link to comment https://forums.phpfreaks.com/topic/198681-reading-and-outputting-file-data/#findComment-1042694 Share on other sites More sharing options...
PFMaBiSmAd Posted April 15, 2010 Share Posted April 15, 2010 You also need to use ENT_QUOTES as the second parameter in the htmlentities() function call so that single quotes in the 'code' being output don't break the html on page. Link to comment https://forums.phpfreaks.com/topic/198681-reading-and-outputting-file-data/#findComment-1042726 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.