You should be familiar with the ini configuration file. At that time, the teacher often talked about opening your php. ini and modifying what you want... For a brief introduction to the configuration structure of the ini configuration file(.)To separate the key/value, a section can be extended or followed by a colon(:)To inherit the section.
Therefore, ZF performs operations on the ini configuration file by zend_config, a subclass of zend_config_ini. When you use zend_config_ini to instantiate an object, specify the IHI file to be read. Then, you can use the object method to read the data in the INI file. The format is as follows:
Zend_config_ini (filename, section, config)
What about the first parameter?FilenameThat is, the file name. The second is the section name in the INI file. The third parameter is not used. If you are interested, read the manual. For example:
Ini configuration file --- file name: Test. ini
[Database] -- this is the so-called section.
Hostname = localhost
Database. type = MySQL
Database. Host = localhost
Database. User = root
Database. Pass = 123
Database. Name = test
Read the Configuration File Content File
$ Filename = "test. ini ";
$ Config = new zend_config_ini ($ filename, 'database ');
Echo $ config-> database-> type;
Echo $ config-> hostname;
Zend_config_ini also supports using the read content as an array. That is, convert the related content to an array. You can use the toarray () method of the zend_config_ini class. This method does not require any parameters. For example, change the configuration file read above:
$ Filename = "test. ini ";
$ Config = new zend_config_ini ($ filename, 'database ');
$ Temp = $ config-> database-> toarray (); // call the toarray () method of the zend_config_ini class
Echo $ temp [type];
Echo $ temp [user];