...

View Full Version : PHP Syntax Highlighting



trancedm
06-05-2005, 06:39 PM
i wanted to do something like this...

ex.


$dbhost = "localhost";
$dbname = "DATABASE_NAME";
$dbuser = "USERNAME";
$dbpass = "PASSWORD";


^^ i want the PHP code to be highlighted even without the PHP tag ("<?php" "?>") is there a way to do that?

i think i could use the highlight_string() function, but how would i display huge chunk of code like the example above

something like this would work


<?php
$code = "echo \"Hello world!\";";
highlight_string($code);
?>


but thats only one a liner code..

anyone can help me out? thanx in advance

Kid Charming
06-05-2005, 07:11 PM
There's highlight_file(), but I don't know how/if removing your php tags will affect your output.

trancedm
06-05-2005, 09:00 PM
There's highlight_file(), but I don't know how/if removing your php tags will affect your output.

i tried highlight_file(), you need the php tag :(

marek_mar
06-05-2005, 10:34 PM
How about stripping the open/close tags after highlighting?

SS2K4
06-06-2005, 06:21 AM
LoL!, i was looking for this a while back, here is a link to a good highlighter you can modify, oh and you dont need the '<?php / ?>' tags, there optional!

Website (http://www.brainerror.net/media/scripts/php/highlight/highlight_code.php)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum