Mega Code Archive

 
Categories / Php / Language Basics
 

A static variable remembering its last value

<?php function birthday(  ){     static $age = 0;     $age = $age + 1;     echo "Birthday number $age<br />"; } $age = 30; birthday(  ); birthday(  ); echo "Age: $age<br />"; ?>