有沒有可能創建一個全局變量在類內可見的配置文件?一些與此類似:如何創建全局配置文件?
的config.php:
$config['host_address'] = 'localhost';
$config['username '] = 'root';
$config['password'] = 'root';
$config['name'] = 'data';
db.php中:
include('config.php');
class DB
{
private $_config = array($config['host_address'], $config['username'], $config['password'], $config['name']);
...
Current屬性:
private $ _config = array();
我不想通過傳輸構造函數到我的Singleton數據庫連接器:
DB::getInstance(array('localhost', 'root', 'root', 'data'));
+ 1 Correctamundo! – webbiedave 2011-05-11 22:51:08