Dan Adams

PHP Display

PHP Display
PHP Mail

Back To:
PHP Scripting

PHP Display

After looking through some trials, it was seen that it is easier to display PHP code on a webpage when you simply insert that text into a <textarea> field. This can become tricky as some editors will not assist with the creation of these fields, but it can be much easier to edit and view the code as a user because of the display of the < symbol.

A text area with the starting and ending PHP brackets:

Even with this method there still may be a change that instead of "<?php" in the source of the HTML file that the user sees they may find "&lt;?php" which is the HTML code for the same thing. With that, this method will allow the user to be able to copy/paste the code from their browser to something else., and it helps to ensure that with any editor the code won't be confused in its formatting with any indentations kept as is.

The downfall of this is that when editing the page, you may not be able to edit the text in whatever editor you are using, if that is the case you would need to look at the source of the page and see where the text box is actually at and then editing it there, if using a CMS style system to generate the pages, it can be possible to automatically format text if to display it as the code in this case.

Webmaster: Dan Adams - Feedback
Copyright 2011 infoChi Christian Computing - Phoenix, Arizona
This page was last updated: January 28, 2011