001-PHP static variable

? < PHP
 function ADDl () 
{ 
    static  $ a = 10;        // definition of the static variable 
    $ a + =. 1 ;
     echo "value of a static variable:." $ A . "<Br>" ; 
} 

function ADD2 () 
{ 
    $ b = 10;               // define local variables 
    $ b + =. 1 ;
     echo "is a local variable b:." $ b . "<br>" ; 
} 

ADD1 ();            // first execution of the function body 
ADD1 ();            // quadratic executing the function body 
ADDl ();            // cubic executing the function body
ADD2 ();            // first execution of the function body 
ADD2 ();            // second execution of the function body 
ADD2 ();            // three times to execute the function body
 
>?

Results are as follows:

 

Guess you like

Origin www.cnblogs.com/tianpan2019/p/10981266.html