Colour Coding PHP Output with HTML
Page last updated on 2011 / 04 / 09All PHP scripts listed on this site use PHP's native "output HTML syntax highlighted source" function that can be used from the command line in this fashion.
php -s path_to_php_script.php > output_file.txt
Here is an example:
<?php
/*
This is a comment
*/
error_reporting(E_ALL);
ini_set("display_errors", 1);
function test_function()
{
echo 123;
echo "This is a test\n";
}
// This is another comment
?>
GeSHi
Another option is to use the comprehensive syntax highlighter GeSHi, which can color-code a number of languages and markup as well as PHP, including MySQL and bash for example. The following is the same code run through the GeSHi highlighter:
<?php /* This is a comment */ error_reporting(E_ALL); ini_set("display_errors", 1); function test_function() { echo 123; echo "This is a test\n"; } // This is another comment ?>
Tweet