Created
February 11, 2015 09:10
-
-
Save noname007/11fefdebda5637e6e36d to your computer and use it in GitHub Desktop.
php 单例模式代码-----
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Singletone{ | |
private static $obj=null; | |
private function __construct(){} | |
static function getInstance() | |
{ | |
if(is_null(self::$obj)) | |
{ | |
echo 111111111,'------'; | |
$class = __CLASS__; | |
self::$obj=new $class; | |
} | |
return self::$obj; | |
} | |
} | |
Singletone::getInstance(); | |
Singletone::getInstance(); | |
Singletone::getInstance(); | |
Singletone::getInstance(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment