Warning: file_put_contents(): Only -1 of 55 bytes written, possibly out of free disk space in /var/www/html/index.php on line 3

Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/index.php:3) in /var/www/html/cache.php on line 23

Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/index.php:3) in /var/www/html/cache.php on line 24

Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/index.php:3) in /var/www/html/cache.php on line 25
highlight_file ignore_user_abort Misc. PHP Manual highlight_string (PHP 4, 5) — Syntax highlighting of a string Description mixed ( $str [, bool $return ] ) Outputs or returns syntax highlighted ...
Forum und email

highlight_string

(PHP 4, PHP 5)

highlight_string — Syntax highlighting of a string

Description

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

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

Parameters

str

The PHP code to be highligthed. 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.

ChangeLog

Version Description
4.2.0 The return parameter was added.

Παραδείγματα

Example#1 highlight_string() example

<?php
highlight_string
('<?php phpinfo(); ?>');
?>

The above example will output (in PHP 4):

<code><font color="#000000">
<font color="#0000BB">&lt;?php phpinfo</font><font color="#007700">(); </font><font color="#0000BB">?&gt;</font>
</font>
</code>

The above example will output (in PHP 5):

<code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php phpinfo</span><span style="color: #007700">(); </span><span style="color: #0000BB">?&gt;</span>
</span>
</code>

Notes

Note: This function internally uses the output buffering with this parameter so it can not be used inside ob_start() callback function.

Δείτε επίσης