最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

php單例模式實(shí)現(xiàn)方法分析

 更新時(shí)間:2015年03月14日 11:07:17   作者:work24  
這篇文章主要介紹了php單例模式,實(shí)例分析了單例模式的原理與實(shí)現(xiàn)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下

本文實(shí)例講述了php單例模式實(shí)現(xiàn)方法。分享給大家供大家參考。具體如下:

<?php
/**
 * @copyright 2013 maguowei.com
 * @author Ma Guowei <imaguowei@gmail.com>
 */
/**
 * 單例模式
 * Class Single
 */
class Single
{
  private $name;
  private static $single;
  private function __construct()
  {
  }
  public static function init()
  {
    if(empty(self::$single))
    {
      self::$single = new Single();
    }
    return self::$single;
  }
  public function getName()
  {
    return $this->name;
  }
  public function setName($name)
  {
    $this->name = $name;
  }
}
$s = Single::init();
$s->setName('hhhh');
echo '$s:'.$s->getName();
unset($s);
$m = Single::init();
echo '$m:'.$m->getName();

希望本文所述對(duì)大家的php程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論

北碚区| 佳木斯市| 翼城县| 册亨县| 清远市| 六安市| 卢湾区| 葵青区| 高陵县| 阿坝县| 安溪县| 陇南市| 遂川县| 格尔木市| 永顺县| 舒城县| 离岛区| 南昌县| 南康市| 永胜县| 达拉特旗| 宝坻区| 蕲春县| 格尔木市| 象山县| 宜黄县| 汝城县| 米脂县| 张掖市| 汝南县| 眉山市| 定日县| 嘉黎县| 伽师县| 班玛县| 广南县| 江门市| 榆林市| 合川市| 玉山县| 长春市|