A static variable remembering its last value : static variables « Language Basics « PHP
- PHP
- Language Basics
- static variables
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 />";
?>
Related examples in the same category