PHP单例模式
时间:2014-08-27 14:29:17
收藏:0
阅读:369
<?php class OA { public static $oa = array(); public static $config = array(); public static function setConfig(array $config) { return self::$config = array_merge(self::$config, $config); } public static function user() { oa_import("user"); if (!key_exists(‘user‘, self::$oa) || !is_object(self::$oa[‘user‘])) { self::$oa[‘user‘] = new user(); } return self::$oa[‘user‘]; } }
调用方式:
<?php
OA::setconfig($config); OA::user()->get();
?>
原文:http://www.cnblogs.com/ideaphp/p/3939293.html
评论(0)