note 11104 deleted from function.highlight-string by sniper

From: Date: Thu, 02 Oct 2003 14:25:58 +0000
Subject: note 11104 deleted from function.highlight-string by sniper
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-57616@lists.php.net to get a copy of this message
Note Submitter: maxim@maxim.cx ---- I guess many of you are trying to highlight a piece of PHP code within a text or an article and ... ...somehow it is not "highlighted" I will not go into detailes here on how to split the text - I'll just explain you one simple thing: ::: --- without < ? and ? > nothing will ever get highlighted --- ::: ::: --- Because for Parser it is text and not a code --- ::: so if you have a string like : $string = ' if($myName == \'Maxim Maletsky\') $myEmail = \'maxim@maxim.cx\'; elseif($myName == \'PHPBeginner.com\') $myEmail = \'maxim@phpbeginner.com\'; # And this is all about this test ... '; (Be carefull, you have to escape all these single quotes and backslashes (in case you use single quotes for the $string)) OutPutting it as: highlight_string($string); Won't highlight it at all .. you need < ? and ? > so this is WILL show it appropriatly: highlight_string("&lt;?$string?>"); Hope it will save someone's time ... NOTE : '< ?' has a space between '<' and '?' because it wouldn't be shown here otherwise - you know how to launch the parser, don't you ? Cheers, Maxim Maletsky

« previous php.notes (#57616) next »