php_strip_whitespace()是php中的一个内置函数,用于从源代码中删除所有注释和空格。
null
语法:
string php_strip_whitespace ( $file )
参数: php_strip_whitespace()函数接受一个参数$file。它是指定文件的必需参数。
返回值: 它返回 $file 在成功删除注释和空格后,否则返回空字符串。
例外情况:
- 它适用于PHP5.0.1及更高版本,在以前的版本中返回空字符串。
- 此函数的工作原理与 php-w 命令行。
下面的程序演示了php中的php_strip_whitespace()函数: 节目:
<?php // Simple program to remove comment // using php_strip_whitespace function. // function to calculate fibonacci number function fib( $n ) { if ( $n <= 1) return $n ; return fib( $n - 1) + fib( $n - 2); } // Driver Code $n = 9; fib( $n ); /* * One more multiline comment */ echo php_strip_whitespace( __FILE__ ); // This line also removed ?> |
输出:
<?php function fib($n) { if ($n <= 1) return $n; return fib($n - 1) + fib($n - 2); } $n = 9; fib($n); echo php_strip_whitespace(__FILE__); ?>
参考: http://php.net/manual/en/function.php-strip-whitespace.php
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END