日韩天天综合网_野战两个奶头被亲到高潮_亚洲日韩欧美精品综合_av女人天堂污污污_视频一区**字幕无弹窗_国产亚洲欧美小视频_国内性爱精品在线免费视频_国产一级电影在线播放_日韩欧美内地福利_亚洲一二三不卡片区

php4和php5單態(tài)模式(Singleton Pattern)寫法_PHP教程

編輯Tag賺U幣
教程Tag:暫無Tag,歡迎添加,賺取U幣!

推薦:PHP在Web開發(fā)領域的優(yōu)勢在哪?
在多數(shù)WEB開發(fā)者眼中,ASP和JSP都被認為是領跑者,而PHP卻被認為是個弱小的“掙扎者”,或者說它是一門被貶低為業(yè)余者才使用的語言,不值得參與企業(yè)WEB開發(fā)的競爭。在我看來,PHP沒有

單態(tài)模式(Singleton Pattern) 就是一個類Class只有一個實例存在。(Ensure a class only has one instance, and provide a global point of access to it.)
這個是php5的寫法。

以下為引用的內容:
<?php
class SingletonPhp5{
static private $_instance=null;

function getInstance(){
if(! self::$_instance){
self::$_instance=new self;
}
return self::$_instance;
}

function __construct(){

}

function Show(){
echo 'Singleton on Php5';
}
}

{
$Singleton=SingletonPhp5::getInstance()->Show();
}

這個是php4的寫法,當然此方法在php5下也可以正常運行。

以下為引用的內容:

class SingletonPhp4{
function &getInstance(){
static $_instance=array();
if(empty($_instance)){
$_instance[]= & new SingletonPhp4();

}
return $_instance[0];

}

function SingletonPhp4(){

}

function Show(){
echo 'Singleton on Php4';
}
}

{
$Singleton=SingletonPhp4::getInstance();
$Singleton->Show();
}

分享:自己輕松修復Discuz!數(shù)據(jù)庫技巧
各位站長經(jīng)常會遇到的數(shù)據(jù)庫損壞的錯誤,錯誤來了就去面對,不要慌張,瞎著急是沒有用的。其實熟悉Discuz! 的朋友都知道,Discuz! 后臺自帶數(shù)據(jù)庫修復工具的,如果數(shù)據(jù)庫損壞導致首頁打不開了,

來源:模板無憂//所屬分類:PHP教程/更新時間:2008-08-22
相關PHP教程