Use static variable defined in function : Static « Language Basics « PHP






Use static variable defined in function


 <?php
  increment ();
  increment ();
  increment ();
  function increment (){
      static $a=0;
      echo $a;
      $a++;
  }    
  ?>
           
       








Related examples in the same category

1.Using the static Statement to Remember the Value of a Variable Between Function Calls