Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PHP highlight_string() Function

PHP highlight_string() Function

PHP Misc Reference Manual PHP Misc Reference Manual

Example

PHP syntax highlighting of a string:

");

?>

The browser output of the above code is as follows:

Hello world!

The HTML output of the above code is as follows (view source):

Hello world!  ();  ?>

Run Example »


Definition and Usage

The highlight_string() function performs PHP syntax highlighting on a string. The string is highlighted using HTML tags.

The colors used for highlighting can be set in the php.ini file or by calling the ini_set() function.


Syntax

highlight_string(

string,return

)

Parameters Description
string Required. Specifies the string to highlight.
return Optional. If set to TRUE, this function returns the highlighted code as a string instead of outputting it directly. Default is FALSE.

Technical Details

Return Value: Returns TRUE on success, FALSE on failure.
PHP Version: 4+
Changelog: In PHP 4.2.0, the return parameter was added.

PHP Misc Reference Manual PHP Misc Reference Manual