Welcome Guest, Not a member yet? Register   Sign In
How to load singleton library
#4

[eluser]Unknown[/eluser]
try using the
Code:
class Logger {
    private static $_instance = new Logger();
    private $_fp;
    
    private function __construct()
    {
       $this->_fp = fopen('log.txt', 'a');
    }

    public function __destruct()
    {
        fclose($this->_fp);
    }

    public function log($text)
    {
        // Log stuff...
    }


    public static function getInstance()
    {
        return Logger::$_instance;
    }
}


Messages In This Thread
How to load singleton library - by El Forum - 03-17-2012, 02:17 AM
How to load singleton library - by El Forum - 03-17-2012, 05:20 AM
How to load singleton library - by El Forum - 03-19-2012, 06:18 AM
How to load singleton library - by El Forum - 03-19-2012, 05:36 PM
How to load singleton library - by El Forum - 03-19-2012, 06:09 PM



Theme © iAndrew 2016 - Forum software by © MyBB