Display PHP code

The easiest way to display PHP source code with syntax highlighting is by just renaming the extension of your php script from from .php to .phps (so add an 's'), however not all webservers are configured to display these kind of files and as a result they are downloaded instead of displayed in the browser. PHP has a 'highlight_string' function that can do this job for you.

<?
highlight_string
("
    <? 
    echo "
echo something";
    print ("
this will display the print command and the string");
    ?>
"
);
?>

don't forget to use escape characters !

[ < PHP Scripts ]


© by Sebastien Bruggeman