This code was posted on php.net, it does what you want:
<?
function phphighlight($input) {
$text = spliti("\[code\]|\[\/code\]",$input);
for($i = 0; $i < count($text); $i++) {
if(ereg("(<\?)(.*)(\?>)",$text[$i])) {
ob_start();
highlight_string($text[$i]);
$text[$i] = ob_get_contents();
ob_end_clean();
$text[$i] = "<p class=\"code\">\n".$text[$i]."</p>";
}
else {
$text[$i] = $text[$i];
}
}
$text = implode("",$text);
return $text;
}
?>
It color-codes stuff within
that is also within <?.
I've altered it a bit, though, so it works a little better. (Short tags are highlighted, changed to [code] from something else, forgot what, though)