添加ConfigParser 配置文件解析类

This commit is contained in:
thinkphp
2013-03-29 11:46:35 +08:00
parent 49f94accec
commit 8ac5b41c42
2 changed files with 27 additions and 1 deletions

26
Think/ConfigParser.php Normal file
View File

@@ -0,0 +1,26 @@
<?php
// +----------------------------------------------------------------------
// | TOPThink [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2011 http://topthink.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
// $Id$
namespace Think;
// 配置文件解析类 解析成php数组
class ConfigParser {
public function __construct($content,$type){
$class = '\Think\ConfigParser\Driver\\'.ucwords($type);
$parse = new $class();
return $parse->parse($content);
}
// 解析内容
static public function parse($content,$type){
return new static($content,$type);
}
}

View File

@@ -13,7 +13,7 @@
namespace Think;
// 内容解析类
class Parser {
protected $handler = null;
public function __construct($content,$type){
$class = '\Think\Parser\Driver\\'.ucwords($type);
$parse = new $class();