update : 2015.11.03
php.shukuma.com

검색:
 
 
Syntax highlighting of a string

highlight_string

(PHP 4, PHP 5)

highlight_stringSyntax highlighting of a string

설명

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.

인수

str

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.

반환값

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.

예제

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>

주의

Note:

return 인수와 함께 사용할 때, 내부적으로 출력 버퍼링을 사용합니다. 그러므로, ob_start() 콜백 함수 안에서는 사용할 수 없습니다.

The HTML markup generated is subject to change.

참고