Jump to content

Inserting HTML code into HTML?


WebCheez

Recommended Posts

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

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);
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.