need to display some php/html code on my webpage

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
me666
Forum Commoner
Posts: 87
Joined: Wed Oct 08, 2008 5:04 pm

need to display some php/html code on my webpage

Post by me666 »

i have a file, file A... i want to display the contents of that file on a webpage, i have done this but as file A is html/php it displays part of the code but displays other parts as you would see them upon loading file A as a webpage.. i just want to display the code as text.. any ideas?
thank you :)
User avatar
iankent
Forum Contributor
Posts: 333
Joined: Mon Nov 16, 2009 4:23 pm
Location: Wales, United Kingdom

Re: need to display some php/html code on my webpage

Post by iankent »

use htmlspecialchars() to format the text - it'll replace things like < with < making sure it shows up as text not HTML :)

edit: e.g.
$text = "<html>blah</html";
$text = htmlspecialchars($text);

hth
me666
Forum Commoner
Posts: 87
Joined: Wed Oct 08, 2008 5:04 pm

Re: need to display some php/html code on my webpage

Post by me666 »

ah ha, excellent thanks for the quick response :)
Post Reply