Page 2 of 2

Posted: Tue Aug 28, 2007 11:19 am
by RobertGonzalez
You don't need to final the getInstance method, though you might want to final the constructor and make it private:

Code: Select all

<?php
class Database {
    private $instance = null;

    final private function __construct() {}

    public static function getInstance() {
        if (null === self::$instance) {
            self::$instance = new self();
        }

        return self::$instance;
    }

    /* ... the rest of the class code ... */
}
?>