954,585 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

coloring of source code

hello,
today i visited the source code section of daniweb and i was amazed to see that codes inside text box were colored according to their syntax.here is the url of the page.
http://www.daniweb.com/code/snippet25.html
in which language this is coded .can i do this in php .can anybody provide me some help.perhaps cscgal can help me out.

ashishjha54
Light Poster
28 posts since May 2005
Reputation Points: 10
Solved Threads: 0
 

The color coding was accomplished by a perl syntax highlighter known as the beautifier ( www.beautifier.org ), later ported to php. Alternatively, there are two built-in php functions known as highlight_string() and highlight_file() which output syntax highlighted PHP. For example, [php]

<?php
highlight_string('<?php phpinfo(); ?>');
?> [/php]

For more information,
http://us4.php.net/manual/en/function.highlight-string.php
http://us4.php.net/manual/en/function.highlight-file.php

cscgal
The Queen of DaniWeb
Administrator
19,432 posts since Feb 2002
Reputation Points: 1,474
Solved Threads: 230
 

i thought i will not get reply, thats why i started coding my own function.my function replaced all the keywords with custom colors and it also changed the colors of the comments, but it had some bugs.but now i know the site i will be able to complete my function easily.

ashishjha54
Light Poster
28 posts since May 2005
Reputation Points: 10
Solved Threads: 0
 

also make sure to check out GeSHi

http://qbnz.com/highlighter/

this will highlight virtually any language you can think of and has sooo many options

paradox814
Posting Whiz
351 posts since Oct 2004
Reputation Points: 13
Solved Threads: 4
 

I use PHP Coder Pro.... Nice utility with some built in functionality... Best of all... it is FREE!

www.phpide.com/go/downloads.htm

cputek2k
Newbie Poster
11 posts since May 2005
Reputation Points: 10
Solved Threads: 0
 

I use PHP Coder Pro.... Nice utility with some built in functionality... Best of all... it is FREE!

www.phpide.com/go/downloads.htm



hello cputek2k,
we are talking about highlighting source codes in web-pages not in IDE.if you know about it ,please tell me. the link u posted was down,but i guessed from the url that it could be IDE download site.

ashishjha54
Light Poster
28 posts since May 2005
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You