PHP highlight_string () function
Examples
The string of PHP syntax highlighting:
<html>
<body>
<?php
highlight_string("Hello world! <?php phpinfo(); ?>");
?>
</body>
</html>
<body>
<?php
highlight_string("Hello world! <?php phpinfo(); ?>");
?>
</body>
</html>
Browser output of the code above is as follows:
Hello world! <?php phpinfo (); ?>
HTML output of the code above is as follows (view source):
<html>
<body>
<code>
<span style="color: #000000">Hello world!
<span style="color: #0000BB"><?php phpinfo</span>
<span style="color: #007700">(); </span>
<span style="color: #0000BB">?></span>
</span>
</code>
</body>
</html>
<body>
<code>
<span style="color: #000000">Hello world!
<span style="color: #0000BB"><?php phpinfo</span>
<span style="color: #007700">(); </span>
<span style="color: #0000BB">?></span>
</span>
</code>
</body>
</html>
Running instance »
Definition and Usage
highlight_string () function strings PHP syntax highlighting. String by using HTML tags highlighted.
Color used to highlight the php.ini file can be set or by calling ini_set () function set.
grammar
highlight_string( string,return )
参数 | 描述 |
---|---|
string | 必需。规定要高亮显示的字符串。 |
return | 可选。如果该参数设置为 TRUE,该函数将以字符串形式返回高亮显示的代码,而不是直接进行输出。默认是 FALSE。 |
technical details
return value: | If successful it returns TRUE, on failure returns FALSE. |
---|---|
PHP version: | 4+ |
Update log: | Added in PHP 4.2.0 The return parameter. |
PHP Misc Reference Manual