Skip to content

Instantly share code, notes, and snippets.

@noname007
Created February 11, 2015 09:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save noname007/11fefdebda5637e6e36d to your computer and use it in GitHub Desktop.
Save noname007/11fefdebda5637e6e36d to your computer and use it in GitHub Desktop.
php 单例模式代码-----
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