所以看到这篇文章的时候,我也才刚刚知道,原来,还有一个dba的函数可以用,嗯,仔细看了一下dba这个函数的installtion,发现支持inifile也是从PHP5才开始实现的。好吧,相应的dba相关的可以看看这里:http://www.PHP.net/manual/en/dba.installation.PHP,详细的还是看这里吧:http://www.PHP.net/manual/en/book.dba.PHP OK,上原文,它来自于:http://www.cardii.net/PHP-spl-parse-ini-file/。 曾经介绍过SPL的各类型接口和迭代器。今天,在浏览PHP源码目录时,发现有个解析INI文件的例子,觉得不错,于是整理了一个实例,拿来分享下。 在程序中,配置文件不可或缺,特别是商城,CMS之类的产品,不同的客户需求不同,当然,不会每个客户开发一套程序,好办法的是每个客户 有一套不同的配置文件。适合做配置文件的我曾经也说过,主要有四类:PHP数组(几乎其他的配置方法最终都是解析成为PHP数组),XML,YAML和 INI。今天只讲INI文件。ZendFramework使用此配置。 下看个DbaReader类。文件名为 DbaReader.PHP:
<div class="codetitle"><a style="CURSOR: pointer" data="14333" class="copybut" id="copybut14333" onclick="doCopy('code14333')"> 代码如下: