View Full Version : PHP sample codes on websites

Len Whistler
08-01-2007, 04:20 AM
How do you have PHP sample codes on .php pages that don't process? <code></code> doesn't work. I would like output like this:

echo "sample";

Without it echoing anything and <?php being displayed.

08-01-2007, 04:33 AM
You need to use htmlentities() so that things like < > are not interpreted by the browser and are instead treated as literal characters and are displayed.

Len Whistler
08-01-2007, 04:38 AM
Thanks CFMaBiSmAd ..... htmlentities() is on page 379 of my PHP book and I will look into it.

08-01-2007, 02:51 PM
also there is PHP classes out there that will put your code into colour coded output just like it does on these forums i think i seen one on phpclasses.org a while ago.

08-01-2007, 05:06 PM
show_source(); ? But then thats for an entire page.

08-01-2007, 05:13 PM
i thought of that but as he mentioned sample code i thought i would direct him in a class...