PHP highlight_file () function
Examples
Test file ( "test.php") were PHP syntax highlighting:
<html>
<body>
<?php
highlight_file("test.php");
?>
</body>
</html>
<body>
<?php
highlight_file("test.php");
?>
</body>
</html>
Browser output of the code above is as follows (depending on the contents of the document):
<html>
<body>
<?php
echo ( "test.php" );
?>
</body>
</html>
<body>
<?php
echo ( "test.php" );
?>
</body>
</html>
HTML output of the code above is as follows (view source):
<html>
<body>
<code><span style="color: #000000">
<html>
<br /><body>
<br /><span style="color: #0000BB"><?php
<br /></span><span style="color: #007700">echo (</span><span style="color: #DD0000">"test.php"</span><span style="color: #007700">);
<br /></span><span style="color: #0000BB">?>
<br /></span></body>
<br /></html></span>
</code>
</body>
</html>
<body>
<code><span style="color: #000000">
<html>
<br /><body>
<br /><span style="color: #0000BB"><?php
<br /></span><span style="color: #007700">echo (</span><span style="color: #DD0000">"test.php"</span><span style="color: #007700">);
<br /></span><span style="color: #0000BB">?>
<br /></span></body>
<br /></html></span>
</code>
</body>
</html>
Running instance »
Definition and Usage
highlight_file () function of the file PHP syntax highlighting. Syntax highlighted by using HTML tags.
Tip: for the highlight color can be set via the php.ini file or by calling the ini_set () function set.
Note: When using this function, the entire file will be displayed, including passwords and other sensitive information!
grammar
highlight_file( filename,return )
参数 | 描述 |
---|---|
filename | 必需。规定要显示的文件。 |
return | 可选。如果该参数设置为 TRUE,该函数将以字符串形式返回高亮显示的代码,而不是直接进行输出。默认是 FALSE。 |
technical details
return value: | If the return parameter is set to TRUE, the function will return a string highlighted code, rather than directly output. Otherwise, if successful returns TRUE, on failure returns FALSE. |
---|---|
PHP version: | 4+ |
Update log: | Since PHP 4.2.1 onwards, this function is now also affected by safe_mode and open_basedir affected. However, in PHP 5.4 is removed in safe_mode. Added in PHP 4.2.0 The return parameter. |
PHP Misc Reference Manual