php_strip_whitespace
返回删除注释和空格后的PHP源码
PHP 4 >= 4.3.0, PHP 5, PHP 7, PHP 8
php_strip_whitespace() 函数用于返回去除PHP源码文件中注释和多余空白字符后的代码。它不会执行该PHP脚本,只是读取并处理其内容。该函数通常用于分析、优化或者显示PHP代码时使用。
php_strip_whitespace(string $filename): string
返回去除注释和多余空格后的PHP代码字符串。如果文件无法读取,将返回空字符串。
<?php $clean_code = php_strip_whitespace('example.php'); echo $clean_code; ?>
上面的示例中,php_strip_whitespace() 读取 example.php 文件的内容,移除其注释和空白后,返回结果并通过 echo 输出。该函数不会影响原文件内容。