1. 首页
  2. 数据库
  3. 其它
  4. php设计模式 Singleton(单例模式)

php设计模式 Singleton(单例模式)

上传者: 2020-12-22 23:26:59上传 PDF文件 27.83KB 热度 33次
复制代码 代码如下: <?php /** * 单例模式 * * 保证一个类仅有一个实例,并提供一个访问它的全局访问点 * */ class Singleton { static private $_instance = null; private function __construct() { } static public function getInstance() { if(is_null(self::$_instance)) { self::$_instance = new Singleton(); } return self::$_instance; } public fun
下载地址
用户评论