Use static variable defined in function : Static « Language Basics « PHP
- PHP
- Language Basics
- Static
Use static variable defined in function
<?php
increment ();
increment ();
increment ();
function increment (){
static $a=0;
echo $a;
$a++;
}
?>
Related examples in the same category