Book HomePHP CookbookSearch this book

5.6. Using Static Variables

5.6.2. Solution

Declare the variable as static:

function track_times_called( ) {
    static $i = 0;
    $i++;
    return $i;
}


Library Navigation Links

Copyright © 2003 O'Reilly & Associates. All rights reserved.