File tree Expand file tree Collapse file tree 1 file changed +3
-2
lines changed
ThinkPHP/Lib/Driver/TagLib Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Original file line number Diff line number Diff line change @@ -690,6 +690,7 @@ public function _for($attr, $content){
690690 $ step = 1 ;
691691 $ comparison = 'lt ' ;
692692 $ name = 'i ' ;
693+ $ rand = rand (); //添加随机数,防止嵌套变量冲突
693694 //获取属性
694695 foreach ($ this ->parseXmlAttr ($ attr , 'for ' ) as $ key => $ value ){
695696 $ value = trim ($ value );
@@ -706,8 +707,8 @@ public function _for($attr, $content){
706707 }
707708 }
708709
709- $ parseStr = '<?php $__FOR_START__ = ' .$ start .';$__FOR_END__ = ' .$ end .'; ' ;
710- $ parseStr .= 'for($ ' .$ name .'=$__FOR_START__ ; ' .$ this ->parseCondition ('$ ' .$ name .' ' .$ comparison .' $__FOR_END__ ' ).';$ ' .$ name .'+= ' .$ step .'){ ?> ' ;
710+ $ parseStr = '<?php $__FOR_START_ ' . $ rand . ' __ = ' .$ start .';$__FOR_END_ ' . $ rand . ' __ = ' .$ end .'; ' ;
711+ $ parseStr .= 'for($ ' .$ name .'=$__FOR_START_ ' . $ rand . ' __ ; ' .$ this ->parseCondition ('$ ' .$ name .' ' .$ comparison .' $__FOR_END_ ' . $ rand . ' __ ' ).';$ ' .$ name .'+= ' .$ step .'){ ?> ' ;
711712 $ parseStr .= $ content ;
712713 $ parseStr .= '<?php } ?> ' ;
713714 return $ parseStr ;
You can’t perform that action at this time.
0 commit comments