joshblue Posted July 20, 2009 Share Posted July 20, 2009 I have a text file. it contains some text with some html tags. ex <body> some text... </body> Something like that... My problem is whenever I'm reading the text file and echo it, it didn't display the tags. Well, I know PHP really don't display tags so I'm wondering if there's a way to display the contents of the text file it as it is... Link to comment https://forums.phpfreaks.com/topic/166570-solved-echo-the-tags/ Share on other sites More sharing options...
o3d Posted July 20, 2009 Share Posted July 20, 2009 echo '<pre>'; echo file_get_contents('/path/to/txt/filename'); echo '</pre>'; that should display the contents of the text file including the tag elements Link to comment https://forums.phpfreaks.com/topic/166570-solved-echo-the-tags/#findComment-878363 Share on other sites More sharing options...
Kieran Menor Posted July 20, 2009 Share Posted July 20, 2009 Rather, echo htmlspecialchars(file_get_contents('/path/to/txt/filename')); Link to comment https://forums.phpfreaks.com/topic/166570-solved-echo-the-tags/#findComment-878368 Share on other sites More sharing options...
joshblue Posted July 20, 2009 Author Share Posted July 20, 2009 echo '<pre>'; echo file_get_contents('/path/to/txt/filename'); echo '</pre>'; that should display the contents of the text file including the tag elements Thank you for the reply. But I already tested that way and it didn't show the tag elements. Link to comment https://forums.phpfreaks.com/topic/166570-solved-echo-the-tags/#findComment-878370 Share on other sites More sharing options...
joshblue Posted July 20, 2009 Author Share Posted July 20, 2009 Rather, echo htmlspecialchars(file_get_contents('/path/to/txt/filename')); This one work. I guess it needs that htmlspecialchars() to reveal the tags. Thank you very much! Link to comment https://forums.phpfreaks.com/topic/166570-solved-echo-the-tags/#findComment-878373 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.