static variables : static variables « Language Basics « PHP






static variables

 
<?php

function keep_track() { 
   STATIC $count  = 0;
   $count++;
   print $count;
   print "<br>";
} 

keep_track();
keep_track();
keep_track(); 

?>
  
  








Related examples in the same category

1.A static variable remembering its last value
2.Using the static Statement to Remember the Value of a Variable Between Function Calls
3.Using the static modifier to change a member or method so it is accessible without instantiating the class
4.Working with Static Variables in Functions