highlight_file
(PHP 4, PHP 5, PHP 7, PHP 8)
highlight_file — 语法高亮一个文件
说明
使用 PHP 内置的语法高亮器所定义的颜色,打印输出或者返回
filename
文件中语法高亮版本的代码。
许多服务器配置了自动高亮 phps 扩展的文件。比如,访问 example.phps 会显示语法高亮后的文件。添加以下一行代码到 httpd.conf 使此生效:
AddType application/x-httpd-php-source .phps
更新日志
版本 | 说明 |
---|---|
8.3.0 | 由此产生的 HTML 有所改变。 |
注释
警告
应当注意在使用 highlight_file() 时,确认没有在不经意间泄漏敏感信息,类似密码或者其他任何具有潜在安全风险的信息。
注意:
当使用了
return
参数时,本函数使用其内部输出缓冲,因此不能在 ob_start() 回调函数的内部使用。
+添加备注
用户贡献的备注 1 note
csst0266 at cs dot uoi dot gr ¶
20 years ago
Here is a simple, yet useful, tip... Issuing the following command under a Unix-like OS:
ln -s your_script.php your_script.phps
Will result in the creation of a symbolic link (called your_script.phps) to the source code (your_script.php). This way you have (apart from the source code .php) the highlighted version of your script (.phps) accessible via your web browser.
备份地址:http://www.lvesu.com/blog/php/function.highlight-file.php