From 8ac5b41c42ad765fd3b4fccc0b05fd923448a676 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Fri, 29 Mar 2013 11:46:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0ConfigParser=20=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E6=96=87=E4=BB=B6=E8=A7=A3=E6=9E=90=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Think/ConfigParser.php | 26 ++++++++++++++++++++++++++ Think/Parser.php | 2 +- 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 Think/ConfigParser.php diff --git a/Think/ConfigParser.php b/Think/ConfigParser.php new file mode 100644 index 00000000..e2f3ad44 --- /dev/null +++ b/Think/ConfigParser.php @@ -0,0 +1,26 @@ + +// +---------------------------------------------------------------------- +// $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); + } +} \ No newline at end of file diff --git a/Think/Parser.php b/Think/Parser.php index 938a79d9..09554a76 100644 --- a/Think/Parser.php +++ b/Think/Parser.php @@ -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();