【发布时间】:2011-04-26 13:43:21
【问题描述】:
想知道在构造函数中解析INI文件是ok还是有更优化的流程?
所以我当前的过程是在实例化类的同时传递 INI 文件,如下所示:
include_once('/path/to/class.php');
$bar = new Foo('/path/to/class.ini');
$bar->runProcess();
所以在我的类构造函数中我有这样的东西:
public function __construct($ini_file) {
$ini = parse_ini_file($ini_file, true);
// Then set all the variables I need here from the INI
$this->variable_setting = $ini['ini_section']['ini_variable'];
}
【问题讨论】:
标签: php optimization configuration initialization ini