The subject of this tutorial will be how PHP code can be colored when you publish it within page text.
We have had inquires about how we are coloring the PHP code on our pages, so we decided to create a simple tutorial.
There are many ways to, but the one that will work on almost all platforms will be to use the built in option inside PHP.
The option is called ‘highlight_strin()’ and has syntax like:
highlight_string ( string $str [, bool $return = false / true ] )
"It returns a syntax highlighted version of the given PHP code using the colors defined in the built-in syntax highlighter for PHP."
It can be used as for $str you will put the PHP code that you want colored, and for the optional $return you can put 'true' or 'false', or as we are going to do in our example, to leave it unused.
Let’s take for example a simple MySQL connection test script:

