PHP highlight_string() Function

The highlight_string() function outputs a string with the PHP syntax highlighted. The string is highlighted by using HTML tags.The colors used for highlighting can be set in the php.ini file or with the ini_set() function.

mixed highlight_string ( string $str [, bool $return = FALSE ] )

Outputs or returns html markup for a syntax highlighted version of the given PHP code using the colors defined in the built-in syntax highlighter for PHP.

Example -

ParameterDescription
strRequired. Specifies the string to highlight
returnSet this parameter to TRUE to make this function return the highlighted code.

Return Values

If return is set to TRUE, returns the highlighted code as a string instead of printing it out. Otherwise, it will return TRUE on success, FALSE on failure.