Classes variables

class MyClass
{
    const MY\_CONST       = 'value';
    static $staticVar    = 'static';
    // Visibility
    public static $var1  = 'pubs';
    // Class only
    private static $var2 = 'pris';
    // The class and subclasses
    protected static $var3 = 'pros';
    // The class and subclasses
    protected $var6      = 'pro';
    // The class only
    private $var7        = 'pri';  
}

Access statically

echo MyClass::MY\_CONST;   # => value
echo MyClass::$staticVar; # => static
Comments