Think\parser类 改进

This commit is contained in:
thinkphp
2013-04-01 17:24:17 +08:00
parent 37359db93c
commit fb82fe8596

View File

@@ -14,11 +14,15 @@ namespace Think;
// 内容解析类 // 内容解析类
class Parser { class Parser {
static private $handler = [];
// 解析内容 // 解析内容
static public function parse($content,$type){ static public function parse($content,$type){
$class = '\\Think\\Parser\\Driver\\'.ucwords($type); if(!isset(self::$handler[$type])) {
$parse = new $class(); $class = '\\Think\\Parser\\Driver\\'.ucwords($type);
return $parse->parse($content); self::$handler[$type] = new $class();
}
return self::$handler[$type]->parse($content);
} }
// 调用驱动类的方法 // 调用驱动类的方法