LonghornPHP 2026

Voting

: min(two, three)?
(Example: nine)

The Note You're Voting On

sideshowAnthony at googlemail dot com
10 years ago
The static keyword can still be used (in a non-oop way) inside a function. So if you need a value stored with your class, but it is very function specific, you can use this:

class aclass {
    public static function b(){
        static $d=12; // Set to 12 on first function call only
        $d+=12;
        return "$d\n";
    }
}

echo aclass::b(); //24
echo aclass::b(); //36
echo aclass::b(); //48
echo aclass::$d; //fatal error

<< Back to user notes page

To Top