Skip to content

Latest commit

 

History

History
36 lines (27 loc) · 379 Bytes

File metadata and controls

36 lines (27 loc) · 379 Bytes

PHP Tutorial: Classes

Chapter 4: Static Classes

// Foo.php

class Foo
{

    /**
     * @var Foo $foo
     */
    private static $foo;

    function __construct()
    {
        self::$foo = new self();
    }

    /**
     * @return Foo
     */
    public static function getFoo()
    {
        return self::$foo;
    }
}
// test.php

Foo::getFoo();