note 95217 added to language.oop5.static
| From: | JayCain at osu1 dot php dot net | Date: | Fri, 18 Dec 2009 22:45:05 +0000 |
| Subject: | note 95217 added to language.oop5.static | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-164125@lists.php.net to get a copy of this message | ||
Regarding the initialization of complex static variables in a class, you can emulate a static
constructor by creating a static function named something like init() and calling it immediately
after the class definition.
<?php
class Example {
private static $a = "Hello";
private static $b;
public static function init() {
self::$b = self::$a . " World!";
}
}
Example::init();
?>
----
Server IP: 69.147.83.197
Probable Submitter: 72.148.10.234
----
Manual Page -- http://www.php.net/manual/en/language.oop5.static.php
Edit -- https://master.php.net/note/edit/95217
Del: integrated -- https://master.php.net/note/delete/95217/integrated
Del: useless -- https://master.php.net/note/delete/95217/useless
Del: bad code -- https://master.php.net/note/delete/95217/bad+code
Del: spam -- https://master.php.net/note/delete/95217/spam
Del: non-english -- https://master.php.net/note/delete/95217/non-english
Del: in docs -- https://master.php.net/note/delete/95217/in+docs
Del: other reasons-- https://master.php.net/note/delete/95217
Reject -- https://master.php.net/note/reject/95217
Search -- https://master.php.net/manage/user-notes.php