Recently I learned from the thinkphp ' Runtime_allinone ' experience: not afraid of caching more, afraid of the call chaos, simply all the common files are merged into a file, not beautiful ...
Copy CodeThe code is as follows:
function Strip_whitespace ($content) {
$STRIPSTR = ";
Analysis of PHP source code
$tokens = Token_get_all ($content);
$last _space = false;
for ($i = 0, $j = count ($tokens); $i < $j; $i + +) {
if (is_string ($tokens [$i])) {
$last _space = false;
$stripStr. = $tokens [$i];
}
else{
Switch ($tokens [$i][0]) {
Filter various PHP comments
Case T_comment:
Case T_doc_comment:
Break
Filter spaces
Case T_whitespace:
if (! $last _space) {
$stripStr. = ';
$last _space = true;
}
Break
Default
$last _space = false;
$stripStr. = $tokens [$i][1];
}
}
}
return $stripStr;
}
This custom function effectively solves the PHP_STRIP_WHITESPACE system built-in comment whitespace function does not correctly understand <<
How to use
Copy the code code as follows:
$str = strip_whitespace ('!--? php '. $str)
before you have to splice this, I do not understand, do not splice words to execute the result is the wrong result
php_strip_whitespace
String php_strip_whitespace (string$filename)
If it's just a single file and there's no heredoc. , it is also recommended to use the shortcut
php_strip_whitespace function
http ://www.bkjia.com/phpjc/328031.html www.bkjia.com true http:// www.bkjia.com/PHPjc/328031.html techarticle recently I thinkphp from the ' Runtime_allinone ' learn from the experience: not afraid of caching more, afraid of the call chaos, simply will all the commonly used files merged into a file, not beautiful ... Copy ...