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

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

WBOY
Release: 2016-06-13 10:12:50
Original
778 people have browsed it

为何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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template