how to display php code read only on a .php page?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Pash
Forum Newbie
Posts: 7
Joined: Mon Jan 05, 2004 4:30 am

how to display php code read only on a .php page?

Post by Pash »

Hi there,

I have been searching for ages for code that will allow me to display php code stored in a databse on a page that will ignore the php syntax as ive typed it in a form. Alot like the forums here with the code tags. Can ne1 point me to a tutorial or give me some examples, will be greatly apprechiated thx

Pash
User avatar
mikusan
Forum Contributor
Posts: 247
Joined: Thu May 01, 2003 1:48 pm

Post by mikusan »

Correct me if i am worng, if you just want to display PHP code, with no fancy coloring, you just don't include the <?php -- ?> php tags....
Or just regex and aget rid of them depending on what you are trying to do.

Most of my code uses concatenation anyways to parse my HTML templates, so whe i want to show the code i just concatenate a string containing the php code.

But that's the basics anyways.
Pash
Forum Newbie
Posts: 7
Joined: Mon Jan 05, 2004 4:30 am

Post by Pash »

thx for your help m8, i never just thought about leaving the tags out lol :(, but if for good practice i did does anybody know other ways to do it.

Thanks again
User avatar
DuFF
Forum Contributor
Posts: 495
Joined: Tue Jun 24, 2003 7:49 pm
Location: USA

Post by DuFF »

Check out highlight_file in the PHP manual.
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

Or just replace < and > with the html entities - < >
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

Image
Post Reply