修正template一处解析错误

This commit is contained in:
thinkphp
2015-12-27 15:12:41 +08:00
parent a2dbc76883
commit 9060a4dd8c

View File

@@ -591,9 +591,9 @@ class Template
$flag = substr($str, 0, 1); $flag = substr($str, 0, 1);
switch ($flag) { switch ($flag) {
case '$': // 解析模板变量 格式 {$varName} case '$': // 解析模板变量 格式 {$varName}
$this->parseVar($str);
// 是否带有?号 // 是否带有?号
if (false !== $pos = strpos($str, '?')) { if (false !== $pos = strpos($str, '?')) {
$this->parseVar($str);
$array = preg_split('/([!=]={1,2}|(?<!-)[><]={0,1})/', substr($str, 0, $pos), 2, PREG_SPLIT_DELIM_CAPTURE); $array = preg_split('/([!=]={1,2}|(?<!-)[><]={0,1})/', substr($str, 0, $pos), 2, PREG_SPLIT_DELIM_CAPTURE);
$name = trim($array[0]); $name = trim($array[0]);
$this->parseVarFunction($name); $this->parseVarFunction($name);
@@ -636,6 +636,7 @@ class Template
} }
} }
} else { } else {
$this->parseVar($str);
$this->parseVarFunction($str); $this->parseVarFunction($str);
$str = '<?php echo ' . $str . '; ?>'; $str = '<?php echo ' . $str . '; ?>';
} }