Page 1 of 1

code color

Posted: Wed Jan 14, 2009 7:19 am
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..

Re: code color

Posted: Wed Jan 14, 2009 8:14 am
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

Re: code color

Posted: Wed Jan 14, 2009 8:19 am
by jaoudestudios
There are jquery libraries out there that will do it for you.

Re: code color

Posted: Wed Jan 14, 2009 12:15 pm
by Fishbone
thanks, i was thinking about tons code lines :D
uh, so simple
thank you!