Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to display script on page without it resolving or executing. 1

Status
Not open for further replies.

southbeach

Programmer
Jan 22, 2008
879
US
I am working on a module where articles can be published. These articles will have HTML, JS, PHP and other type of scripting tags.

Right now, all looks good except that when I used the < pre >
tag to display the code, the code appears to be resolved and not shown.

I sort of want to do same as it is done here, I can post my code and it shows as content of my postings ... How is this done?

Thank you all in advance!
 
it would be very strange if you were executing code that came out of your database. so i guess your issue is one of html encoding.

use htmlspecialchars() on the output before wrapping it in <pre><code> tags
 
That helped ... Thanks!

I ended up using
Code:
<pre>
<?PHP
echo htmlspecialchars('
all of my PHP and HTML code
');
?>
</pre>

and the code is displayed as content.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top