导航首页 » 技术教程 » PHP:php_strip_whitespace()的用法_misc函数
PHP:php_strip_whitespace()的用法_misc函数 147 2023-12-15   

php_strip_whitespace

(PHP 5)

php_strip_whitespace — 返回删除注释和空格后的PHP源码

说明

string php_strip_whitespace ( string $filename )

返回删除注释和空格后 filename 的PHP源码。这对实际代码数量和注释数量的对比很有用。 此函数与 命令行 下执行 php -w 相似。 commandline.

参数

filename

PHP文件的路径。

返回值

在成功时返回过滤后的代码,或者在失败时返回空字符串。

Note:

此函数在PHP 5.0.1后以所述方式工作。之前它仅会返回一个空字符串。关于更多此BUG的信息与其行为,详见BUG报告 » #29606。

范例

Example #1 php_strip_whitespace() 的例子

<?php
// PHP comment here

/*
 * Another PHP comment
 */

echo        php_strip_whitespace(__FILE__);
// Newlines are considered whitespace, and are removed too:
do_nothing();
?>

以上例程会输出:

<?php
 echo php_strip_whitespace(__FILE__); do_nothing(); ?>

可以注意到PHP的注释已不存在,成为第一个echo语句前的换行和空格。


!!!站长长期在线接!!!

网站、小程序:定制开发/二次开发/仿制开发等

各种疑难杂症解决/定制接口/定制采集等

站长微信:lxwl520520

站长QQ:1737366103