Static Constructors

From: Date: Tue, 05 Oct 2004 23:36:24 +0000
Subject: Static Constructors
Groups: php.internals 
Request: Send a blank email to internals+get-13183@lists.php.net to get a copy of this message
I've put together a rough implementation of static constructors. I'd like to get peoples thoughts about it then I'll either clean it up and submit it or nuke it. Basically the class constructor __cconstruct (have any better ideas?) is called upon the first access to any static property and marks the class entry as initialized. <? class Logger { public static $logfile = null; private static function __cconstruct() { self::$logfile = fopen('log.txt', 'a'); } public static function WriteLine($value) { $value .= PHP_EOL; fputs(self::$logfile, $value, strlen($value)); } } Logger::WriteLine('Static constructors'); ?>

« previous php.internals (#13183) next »