Recently, I learned from thinkphp's 'RUNTIME_ALLINONE' experience: I am not afraid of too many caches, but I am afraid of chaotic calls. Wouldn't it be nice to simply merge all commonly used files into one file? . .
Copy code The code is as follows:
function strip_whitespace($content) {
$stripStr = '';
//Analyze 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 = false; 🎜> return $stripStr;
}
This custom function effectively solves the problem that the built-in comment space function of the php_strip_whitespace system cannot correctly understand <<
How to use it
Copy code
The code is as follows:
$str = strip_whitespace('
You must splice this before. I don’t understand it. If you don’t splice it, the generated result will be wrong.php_strip_whitespace
string php_strip_whitespace (string$filename)
If it is just a single file and there is no heredoc, it is recommended to use the quick
php_strip_whitespace
function
http://www.bkjia.com/PHPjc/328031.htmlwww.bkjia.comtrue
http: //www.bkjia.com/PHPjc/328031.html
TechArticleRecently I learned from thinkphp's 'RUNTIME_ALLINONE' experience: I am not afraid of too many caches, but I am afraid of chaotic calls, so I simply put all Wouldn't it be nice to combine all commonly used files into one file? . . Copy...