Copy code The code is as follows:
function sendHeader($num, $rtarr = null) {
static $sapi = null;
if ($sapi === null) {
$sapi = php_sapi_name();
}
return $sapi++;
Look at the PW source code I discovered that the static keyword is used in the setHeader() function, which is very strange. I have never used it in this way before.
static is used in functions. After declaring a variable once, if the function is called again, it will continue at the initial value. For example, $sapi will be accumulated here.
Copy code The code is as follows:
echo sendHeader(1)."
";
echo sendHeader(2)."
";
echo sendHeader(3)."
";
output:
Copy code The code is as follows:
apache2handler
apache2handles
apache2handlet
It is somewhat similar to global, but The difference is scope. static can only be used on this function.
It’s interesting. Needs further research.
http://www.bkjia.com/PHPjc/325414.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/325414.htmlTechArticleCopy the code The code is as follows: function sendHeader($num, $rtarr = null) { static $sapi = null; if ($sapi === null) { $sapi = php_sapi_name(); } return $sapi++; When looking at the PW source code, I found...