highlight_string()
Use this function as a quick and easy way to view some PHP code. It will add HTML to it, adding color for better readability.
Note that you do need the opening <?php tag (otherwise, it will think it’s plain text - just like a PHP file would).
By default it prints the result. Set the second parameter to true if you want to capture the resulting string instead.
$str = '<pre> <php echo "Hi!"; $name = "Robert"; echo "Hello $name"; ?> The End. '; $new = highlight_string( $str, true ); /* <code><span style="color: #000000"> <pre><br /><span style="color: #0000BB"><?php<br /></span><span style="color: #007700">echo </span><span style="color: #DD0000">"Hi!"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$name </span><span style="color: #007700">= </span><span style="color: #DD0000">"Robert"</span><span style="color: #007700">;<br />echo </span><span style="color: #DD0000">"Hello $name"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?><br /></span><br />The End.<br /></span> </code> */
See the manual entry for highlight_string()
