highlight_string

PHP 4, PHP 5, PHP 7, PHP 8
highlight_string - Syntax highlighting of a string
Manual
Code Examples

highlight_string( string$string, [bool$return = false] ): string|bool

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.

Parameters

string

The PHP code to be highlighted. This should include the opening tag.

return

Set 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.

Notes

Note:

When the return parameter is used, this function uses internal output buffering so it cannot be used inside an ob_start callback function.

The HTML markup generated is subject to change.

Related Functions

Example of highlight_string

Show all examples for highlight_string

PHP Version: