php singleton()
生活随笔
收集整理的這篇文章主要介紹了
php singleton()
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
common.php?
?
<?phpclass CC
{private static $ins;
public static function singleton(){if (!isset(self::$ins)){$c = __CLASS__;self::$ins = new $c;}return self::$ins;}public function EventResult($Id)
{
return $Id;
}
}
?>
?
?
index.php
<html><head><title>測試</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body>
<?php
require 'common.php';
$objCC=CC::singleton();
$r=$objCC->EventResult(7);
print_r($objCC);
echo $r."</br>";
?>
</body></html>
?
總結
以上是生活随笔為你收集整理的php singleton()的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 做个喉镜大概要多少钱?
- 下一篇: 中国机长啥时候播出