note 64100 added to function.highlight-string

From: Date: Fri, 07 Apr 2006 11:31:55 +0000
Subject: note 64100 added to function.highlight-string
Groups: php.notes 
Request: Send a blank email to php-notes+get-107510@lists.php.net to get a copy of this message
stalker, I`m afraid your function has a bug. Whenever a input string will contain a substring: 'color="foo.bar"' it will be replaced by your function, whitch is of course incorrect. Try this: <?php function xhtmlHighlightString( $str, $return=false ) { $hlt = highlight_string( $str, true ); $ret = str_replace( array( '<font color="', '</font>' ), array( '<span style="color: ', '</span>' ), $hlt ); if($return) return $ret; echo $ret; return true; } function xhtmlHilightFile( $path, $return = false ) { return xhtmlHighlightString( file_get_contents( $path ), $return ); } ?> ---- Server IP: 195.136.184.34 Probable Submitter: 212.186.134.168 ---- X-Spam-Status: No, hits=3.4 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER, HTML_FONTCOLOR_UNKNOWN,HTML_MESSAGE autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.highlight-string.php Edit -- http://master.php.net/note/edit/64100 Del: integrated -- http://master.php.net/note/delete/64100/integrated Del: useless -- http://master.php.net/note/delete/64100/useless Del: bad code -- http://master.php.net/note/delete/64100/bad+code Del: spam -- http://master.php.net/note/delete/64100/spam Del: non-english -- http://master.php.net/note/delete/64100/non-english Del: in docs -- http://master.php.net/note/delete/64100/in+docs Del: other reasons-- http://master.php.net/note/delete/64100 Reject -- http://master.php.net/note/reject/64100 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#107510) next »