code color

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
Fishbone
Forum Newbie
Posts: 2
Joined: Wed Jan 14, 2009 7:04 am

code color

Post by Fishbone »

hello,
i'm in my early stage of learning PHP and i need some help,
i'm doing a little site about my school and i need in one section of my website a PHP code.
i've made a posting zone where people post(obviously) C++ source codes for different programs.
i hope that its at ease to help me make a PHP code that colors conditions, comments.. and all the different things like so:

Code: Select all

 
if(x==y) {
i=i+2;
cout<<"'i' has increased"<<endl;
}
 
you people know what i mean and need.
if possible and stuff, please reply and help me out.
Thanks.
ps: sorry for my bad spelling, not from US/UK etc..
User avatar
blue-printf
Forum Newbie
Posts: 12
Joined: Mon Jan 12, 2009 9:27 am

Re: code color

Post by blue-printf »

you could use:
highlight_file()
or
highlight_string()

this highlights php code. (of course C syntax color code is a bit different but it does give you highlighted code)

i believe there are some repositories with functions for highlighting c code or you could make a function yourself. but i think the highlight_string() will do the job good enough
Last edited by blue-printf on Wed Jan 14, 2009 8:20 am, edited 1 time in total.
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Re: code color

Post by jaoudestudios »

There are jquery libraries out there that will do it for you.
Fishbone
Forum Newbie
Posts: 2
Joined: Wed Jan 14, 2009 7:04 am

Re: code color

Post by Fishbone »

thanks, i was thinking about tons code lines :D
uh, so simple
thank you!
Post Reply