Get it on Google Play
Hey check out this LuckyKhel App at:
Get it on Google Play Get it on Google Play
LuckyKhel

Wednesday, 14 September 2011

IT

Using Static Variables


 Problem

You want a local variable to retain its value between invocations of a function.

Solution

Declare the variable as static:
function track_times_called( ) {
    static $i = 0;
    $i++;
    return $i;
}

No comments:

Post a Comment



Hey check out this LuckyKhel App at:
Get it on Google Play Get it on Google Play
LuckyKhel