background image

 
[translation] => Array 

[locale] => zh_CN 

 
[timezone] => Asia/Shanghai 
[system] => Array 

[locale] => aa_DJ.utf8 


 
下面调用父类的构造函数__construct  

, Zend_Config_Ini 的父类是 Zend_Config。

 

class

 Zend_Config 

implements

 Countable, Iterator

Zend_Config 实现了 Countable 接口(包含

count

()方法),Iterator 接口(包含

current,key,next,

rewind

,valid 等方法)

Zend_Config 的构造函数将上面分析的二维数组放到_data 中了。
 
这里注重看两个函数
__set 和__get
魔术方法__get 保证了可以使用 config->field 获取配置值
魔术方法__set 保证了是否可以修改配置文件,set 中就使用到了_allowModifications,如
果这个属性有设置,那么__setter 就可以设置,否则会抛出 Zend_Config is read only 的异
常,allowModifications 也是 options 中设置的属性之一。
 
至此,看文章最前面的 demo 代码
date_default_timezone_set(

$config

->timezone);

这里之所以能使用->timezone 就是使用了__get 而不是 config 中的属性。
Zend 的 Config 机制分析结束。