2007年10月的归档

ZF读取配置文件

| | 评论(0)

1.加载配置文件:
require_once 'Zend/Config/Ini.php';
$config['nestSeparator'] = ':';
$config = new Zend_Config_Ini('/path/to/config.ini', 'staging', $config);

另一种加载文件的方法
Zend_Loader::loadClass('AppController','../application/controllers'); //加载基本控制器
// 加载配置
$config= new Zend_Config_Ini('../application/config.ini', 'reader');

2.config.ini文件示例
[general]
db.adapter = PDO_Oci
db.config.username = cat
db.config.password = dog
db.config.dbname = rabbit

[reader]
reader.LIB_CODE_REDRSTS_CANCEL = 0
reader.LIB_CODE_REDRSTS_ENABLE = 1
reader.LIB_CODE_CERTSTS_CANCEL = 0

3.读取配置文件

$redr=$config->reader->redr_lose;

参考资料:http://www.phpeye.com/zf/zend.config.adapters.ini.html