php_strip_whitespace()是PHP中的內置函數,用於從源代碼中刪除所有注釋和空格。
用法:
string php_strip_whitespace ( $file )
參數:php_strip_whitespace()函數接受單個參數$file。它是指定文件的必需參數。
返回值:成功刪除注釋和空格後,它將返回$file的源代碼,否則將返回空字符串。
異常:
- 它適用於PHP 5.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
相關用法
- PHP abs()用法及代碼示例
 - PHP cos( )用法及代碼示例
 - PHP end()用法及代碼示例
 - PHP sin( )用法及代碼示例
 - PHP each()用法及代碼示例
 - PHP Ds\Map map()用法及代碼示例
 - PHP Ds\Map last()用法及代碼示例
 - PHP Ds\Map xor()用法及代碼示例
 - PHP pi( )用法及代碼示例
 - PHP pow( )用法及代碼示例
 - PHP Ds\Set xor()用法及代碼示例
 - PHP Ds\Map put()用法及代碼示例
 - PHP tan( )用法及代碼示例
 
注:本文由純淨天空篩選整理自R_Raj大神的英文原創作品 PHP | php_strip_whitespace() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
