class User { static function getInstance() { if (self::$instance == NULL) { // If instance is not created yet, will create it. self::$instance = new User(); } return self::$instance; } private function __construct() // Constructor method as private so by mistake developer not crate // second object of the User class with the use of new operator { } private function __clone() // Clone method as private so by mistake developer not crate //second object of the User class with the use of clone. { } function Log($str) { echo $str; } static private $instance = NULL; } User::getInstance()->Log("Welcome User");
用户登录
还没有账号?立即注册
用户注册
投稿取消
文章分类: |
|
还能输入300字
上传中....