Home >Backend Development >PHP Tutorial > 为何STATIC位置不同,结果产生了不同解决方法

为何STATIC位置不同,结果产生了不同解决方法

WBOY
WBOYOriginal
2016-06-13 13:44:151042browse

为何STATIC位置不同,结果产生了不同
  function A( ){
STATIC $a=10;
$a+=10;
echo $a;
}
A( ); // 20
A( ); //20
?>
=====================================================================

  function A( ){
STATIC $a 
  $a=10;
$a+=10;
echo $a;

A( ); //20
A( ); //30
?>


------解决方案--------------------
应该是第一个输出20 ,30 第二个 20,20

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn