note 101350 added to language.oop5.static
| From: | tolean_dj at yahoo dot com | Date: | Sun, 12 Dec 2010 01:09:58 +0000 |
| Subject: | note 101350 added to language.oop5.static | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-174806@lists.php.net to get a copy of this message | ||
Starting with php 5.3 you can get use of new features of static keyword. Here's an example of
abstract singleton class:
<?php
abstract class Singleton {
protected static $_instance = NULL;
/**
* Prevent direct object creation
*/
final private function __construct() { }
/**
* Prevent object cloning
*/
final private function __clone() { }
/**
* Returns new or existing Singleton instance
* @return Singleton
*/
final public static function getInstance(){
if(null !== static::$_instance){
return static::$_instance;
}
static::$_instance = new static();
return static::$_instance;
}
}
?>
----
Server IP: 69.147.83.197
Probable Submitter: 94.62.186.52
----
Manual Page -- http://www.php.net/manual/en/language.oop5.static.php
Edit -- https://master.php.net/note/edit/101350
Del: integrated -- https://master.php.net/note/delete/101350/integrated
Del: useless -- https://master.php.net/note/delete/101350/useless
Del: bad code -- https://master.php.net/note/delete/101350/bad+code
Del: spam -- https://master.php.net/note/delete/101350/spam
Del: non-english -- https://master.php.net/note/delete/101350/non-english
Del: in docs -- https://master.php.net/note/delete/101350/in+docs
Del: other reasons-- https://master.php.net/note/delete/101350
Reject -- https://master.php.net/note/reject/101350
Search -- https://master.php.net/manage/user-notes.php