RE: [PHP] Display HTML/PHP code on a web page
| From: | Jay Blanchard | Date: | Thu, 17 Jul 2003 12:20:49 +0000 |
| Subject: | RE: [PHP] Display HTML/PHP code on a web page | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-155591@lists.php.net to get a copy of this message | ||
[snip]
i'm not sure but i think a tag in html is available which name <code>
and
</code>
[/snip]
You can also put your code between <pre></pre> tags (pre-formatted text)
I do this to display pre formatted text in text area boxes ....
<h3 class="nomargin"><?php print($rowart->title); // article title
?></h3>
By: <?php print($rowart->name); //article author ?><br>
Published: <?php print($rowart->publish); //article date ?><br>
<?php
$thebody = $rowart->body; // results of the article query from the DB
$thebody = ereg_replace(chr(10).chr(13), "</p>\n<p>", $thebody); //
paragraph seperations
// replace <pre> tages with <textarea> tags
$thebody = ereg_replace("<pre>", "<textarea cols=\"80\"
rows=\"10\"
wrap=\"off\">", $thebody);
$thebody = ereg_replace("</pre>", "</textarea>", $thebody);
// print the article out with formatting in place.
print("<p>\n" . $thebody . "\n</p>\n");
?>
HTH!