PHP strip_whitespace() Function

Definition and Usage

The strip_whitespace() function returns the source code file without PHP comments and whitespace characters.

This function is very useful for detecting the actual code volume in scripts.

Syntax

strip_whitespace(filename)
Parameter Description
filename Required. Specifies the filename.

Description

If successful, returns the stripped source code, if failed, returns an empty string.

Note:In PHP 5.0.1, the behavior of this function is consistent with the description above. Before this, it only returned an empty string.

Example

"test.php":

<?php
// PHP comment
/*
*  Another PHP comment
*/
echo php_strip_whitespace      ("test.php");
?>

Output:

<?php
echo php_strip_whitespace("test.php");
?>