php读取配置文件的代码一例
时间:2021-07-01 10:21:17
帮助过:32人阅读
- /**
- * 读取配置文件
- * by bbs.it-home.org
- */
- if (!isset($config)){
- $ARR=file("admin.conf");
- foreach($ARR as $val) {
- $val=chop($val);
- if (ereg('^[[:space:]]*#',$val) || ereg('^[[:space:]]*$',$val))
- continue;
- list($key,$v)=split(":[[:space:]]*",$val,2);
- if (preg_match("/%\{(.+)\}/",$v,$matches)){
- $val=$config[$matches[1]];
- $v=preg_replace("/%\{$matches[1]\}/",$val,$v);
- }
- $config["$key"]="$v";
- }
- echo "
"; - var_dump($config);
- }
|