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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.