Use static variables in function in PHP
Description
The following code shows how to use static variables in function.
Example
<?php//ww w. j a v a 2 s .c om
function keep_track() {
static $count = 0;
$count++;
echo $count;
echo "<br />";
}
keep_track();
keep_track();
keep_track();
?>
The code above generates the following result.