WebCheez Posted May 27, 2011 Share Posted May 27, 2011 How would I make an HTML page look somewhat like this?? HTML Tutorial Here's a basic HTML page: <html> <head><title>HTML page of HTML pageiness.</head> <body> <p>HTML PAGE!!!!!!!!!!!!111!!1111111111111111!!1111111111!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1!1one!!1!!!!!111!!!!!</p> <h1>PIE!!!!!</h1> </body> </html> Like, actually displaying HTML code without rendering it into fancy looking stuff. Quote Link to comment Share on other sites More sharing options...
eMonk Posted May 27, 2011 Share Posted May 27, 2011 You can enclose the html code with any of the following tags: <pre> </pre> <xmp> </xmp> <textarea> </textarea> Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted May 27, 2011 Share Posted May 27, 2011 Either use - htmlentities with the second parameter set to ENT_QUOTES or use highlight_string or highlight_file There are also several open source code highlighters that you can find by searching the Internet. Quote Link to comment Share on other sites More sharing options...
WebCheez Posted May 27, 2011 Author Share Posted May 27, 2011 Nah, I like eMonk's way better, it's simple. Is that PHP, PFM? Thanks. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted May 27, 2011 Share Posted May 27, 2011 You will find that <pre> </pre> doesn't stop the html from being rendered and <xmp> </xmp> is depreciated. Quote Link to comment Share on other sites More sharing options...
WebCheez Posted May 27, 2011 Author Share Posted May 27, 2011 Oh. Oh well, even though it's depriciated, it still works, for now, at least. I would change it if I hadn't just coded a whole bunch of stuff. Quote Link to comment Share on other sites More sharing options...
WebCheez Posted May 27, 2011 Author Share Posted May 27, 2011 Oh, crap, how do you do this when there's PHP in the code? Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted May 27, 2011 Share Posted May 27, 2011 Someone already suggested some of the common ways this is done - <?php // assuming you have the code that is to be displayed in a string ... $code = <<<HEREDOC <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <html xmlns=" http://www.w3.org/1999/xhtml "> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Display code test</title> <script type="text/javascript" src="jquery.js"></script> </head> <body> <?php echo "some php code"; ?> </body> </html> HEREDOC; echo "------------------------ htmlentities method -----------------------<br />"; echo "<code>"; echo nl2br(htmlentities($code,ENT_QUOTES)); echo "</code>"; echo "<br />------------------------ highlight string method -----------------------<br />"; echo highlight_string($code,true); ?> Quote Link to comment Share on other sites More sharing options...
WebCheez Posted May 27, 2011 Author Share Posted May 27, 2011 Thanks! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.