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. Link to comment https://forums.phpfreaks.com/topic/237589-inserting-html-code-into-html/ 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> Link to comment https://forums.phpfreaks.com/topic/237589-inserting-html-code-into-html/#findComment-1220918 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. Link to comment https://forums.phpfreaks.com/topic/237589-inserting-html-code-into-html/#findComment-1220919 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. Link to comment https://forums.phpfreaks.com/topic/237589-inserting-html-code-into-html/#findComment-1220931 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. Link to comment https://forums.phpfreaks.com/topic/237589-inserting-html-code-into-html/#findComment-1220933 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. Link to comment https://forums.phpfreaks.com/topic/237589-inserting-html-code-into-html/#findComment-1220948 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? Link to comment https://forums.phpfreaks.com/topic/237589-inserting-html-code-into-html/#findComment-1220954 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); ?> Link to comment https://forums.phpfreaks.com/topic/237589-inserting-html-code-into-html/#findComment-1220961 Share on other sites More sharing options...
WebCheez Posted May 27, 2011 Author Share Posted May 27, 2011 Thanks! Link to comment https://forums.phpfreaks.com/topic/237589-inserting-html-code-into-html/#findComment-1221066 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.