<div class="codetitle"> <span><a style="CURSOR: pointer" data="9385" class="copybut" id="copybut9385" onclick="doCopy('code9385')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code9385"> <br><?php <BR>$a = array( <br>'a','b','c' <br>); <br>require 'template/demo.php';//引用模板 <br>?> <br> </div> <br>模板文件: <br><div class="codetitle"> <span><a style="CURSOR: pointer" data="1099" class="copybut" id="copybut1099" onclick="doCopy('code1099')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code1099"> <br> <br> <br> <br><meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <br><title> 模板测试 </title> <br> <br> <br>=$a[1]?> <br><pre> <br><?php print_r($a); ?> <br><pre> <br> <br> <br></pre></pre> </div> <br><div class="codetitle"> <span><a style="CURSOR: pointer" data="79073" class="copybut" id="copybut79073" onclick="doCopy('code79073')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code79073"> <br><?php foreach ($a as $value){ ?> <br>键值: =$value?><br> <br><?php } ?> <br>//数组的迭代 <br>//smarty: <br>{foreach item=na from=$a key=key} <br>键值:{$key} <br> <br>{/foreach} <br>//对于PHP程序员那个更好理解呢? <br>//smarty 解析模板还用到正则,PHP的正则效率不会高到哪里去吧... <br> </div>