{"id":3123,"date":"2010-09-09T02:03:27","date_gmt":"2010-09-08T18:03:27","guid":{"rendered":"http:\/\/wp.chunhsin.idv.tw\/?p=3123"},"modified":"2010-09-09T02:03:27","modified_gmt":"2010-09-08T18:03:27","slug":"%e6%94%b9%e6%a8%a1%e4%bb%bfsmarty%e7%9a%84%e6%a6%82%e5%bf%b5","status":"publish","type":"post","link":"https:\/\/wp.chunhsin.idv.tw\/?p=3123","title":{"rendered":"\u6539\u6a21\u4effsmarty\u7684\u6982\u5ff5"},"content":{"rendered":"<p>\u7e7c\u4e4b\u524d\u6a21\u4effxoops\u7684\u6a21\u7d44\u64b0\u5beb\u65b9\u5f0f\u5f8c\uff0c\u4eca\u5929\u7a81\u767c\u5947\u60f3\u6539\u6a21\u4effsmarty\u6a23\u677f\u7684\u6982\u5ff5\u3002<!--more--><\/p>\n<p>\u5c31\u662f\u628a\u6240\u6709\u9700\u8981\u8f38\u51fa\u7684\u8cc7\u6599\u5168\u90e8\u90fd\u4e1f\u7d66\u67d0\u5e7e\u500b\u56fa\u5b9a\u7684\u8b8a\u6578\u627f\u63a5\uff0c\u4f8b\u5982$main\u3002\u6700\u5f8c\u518d\u5224\u65b7\u6709\u6c92\u6709$main\u9019\u500b\u8b8a\u6578\uff0c\u6709\u7684\u8a71\u518d\u5f15\u5165\u6a23\u7248\u6a94\u3002<\/p>\n<p>\u6a23\u677f\u6a94\u7684\u5167\u5bb9\u5176\u5be6\u662f\u55ae\u7d14\u7684HTML\u4e3b\u9ad4\u6a19\u7c64\uff0c\u5728\u5b83\u7684&lt;body&gt;\u6a19\u7c64\u88e1echo php\u8b8a\u6578$main\u3002\u7576\u7136\u8b8a\u6578\u524d\u5f8c\u5fc5\u9808\u518d\u52a0\u4e0aphp\u8b58\u5225\u6a19\u7c64(&lt;?php\u00a0 ?&gt;)\u624d\u884c\u3002<\/p>\n<p>\u56e0\u70ba\u8f38\u51fa\u7d71\u4e00\u7531template.php\u8ca0\u8cac\uff0c\u6240\u4ee5\u627f\u8f09\u8f38\u51fa\u8cc7\u6599\u7684\u8b8a\u6578\u5fc5\u9808\u56fa\u5b9a\u624d\u884c\uff0c\u4f46\u6578\u91cf\u537b\u4e0d\u4e00\u5b9a\u53ea\u80fd\u6709\u4e00\u500b\u3002\u53ef\u4ee5\u5c07\u4e0d\u540c\u7684\u8f38\u51fa\u8cc7\u6599\u64fa\u5230\u4e0d\u540c\u7684\u8b8a\u6578\uff0c\u4f8b\u5982\u5fc5\u9808\u653e\u5728&lt;head&gt;\u7684\u8cc7\u6599\u653e\u5230$head\uff0cjavascript\u7684\u653e\u5230$jsfile\u2026\u7b49\uff0c\u7136\u5f8c\u5728\u6a23\u677f\u6a94\u7684\u9069\u7576\u4f4d\u7f6e\u5c07\u4e4becho\u51fa\u4f86\u5c31\u53ef\u4ee5\u4e86\u3002\u7c21\u6613\u7684smarty\u6982\u5ff5\u5be6\u4f5c\u5c31\u9019\u6a23\u5b8c\u6210\u3002<\/p>\n<h4>\u5be6\u4f5c\u7bc4\u4f8b\uff1a<\/h4>\n<h5>\u300aindex.php\u300b<\/h5>\n<p>&lt;?php<\/p>\n<p style=\"padding-left: 30px;\">include &#8220;db.php&#8221;;\u00a0\u00a0 <span style=\"color: #008000;\">\/\/\u8cc7\u6599\u5eab\u9023\u7dda\u8a2d\u5b9a<\/span><\/p>\n<p style=\"padding-left: 30px;\">$sql=&#8221;select a,b,c from tbl where a&gt;10&#8243;;<\/p>\n<p style=\"padding-left: 30px;\">$res=@mysql_query($sql);<\/p>\n<p style=\"padding-left: 30px;\">if(mysql_num_rows($res)&gt;0){<\/p>\n<p style=\"padding-left: 60px;\">$main=&#8221;&#8221;;<\/p>\n<p style=\"padding-left: 60px;\">while(list($a,$b,$c)=mysql_fetch_row($res)){<\/p>\n<p style=\"padding-left: 90px;\">$main.=&#8221;a+b+c=&#8221;.$a+$b+$c.&#8221;&lt;br\/&gt;&#8221;;<\/p>\n<p style=\"padding-left: 60px;\">}<\/p>\n<p style=\"padding-left: 30px;\">}<\/p>\n<p style=\"padding-left: 30px;\">if($main){<\/p>\n<p style=\"padding-left: 60px;\"><span style=\"color: #ff0000;\">include &#8220;template.php&#8221;;<\/span><\/p>\n<p style=\"padding-left: 30px;\">}<\/p>\n<p>?&gt;<\/p>\n<h5>\u300atemplate.php\u300b<\/h5>\n<p>&lt;!DOCTYPE HTML PUBLIC &#8220;-\/\/W3C\/\/DTD HTML 4.01 Transitional\/\/EN&#8221;&gt;<br \/>\n&lt;html&gt;<br \/>\n&lt;head&gt;<br \/>\n&lt;meta http-equiv=&#8221;content-type&#8221; content=&#8221;text\/html; charset=utf-8&#8243;&gt;<br \/>\n&lt;meta content=&#8221;PSPad editor, www.pspad.com&#8221;&gt;<br \/>\n&lt;title&gt;&lt;\/title&gt;<br \/>\n&lt;\/head&gt;<br \/>\n&lt;body&gt;<\/p>\n<p style=\"padding-left: 30px;\"><span style=\"color: #ff0000;\">&lt;?php<br \/>\necho $main;<br \/>\n?&gt;<\/span><\/p>\n<p>&lt;\/body&gt;<br \/>\n&lt;\/html&gt;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7e7c\u4e4b\u524d\u6a21\u4effxoops\u7684\u6a21\u7d44\u64b0\u5beb\u65b9\u5f0f\u5f8c\uff0c\u4eca\u5929\u7a81\u767c\u5947\u60f3\u6539\u6a21\u4effsmarty\u6a23\u677f\u7684\u6982\u5ff5\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-3123","post","type-post","status-publish","format-standard","hentry","category-php"],"_links":{"self":[{"href":"https:\/\/wp.chunhsin.idv.tw\/index.php?rest_route=\/wp\/v2\/posts\/3123","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wp.chunhsin.idv.tw\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wp.chunhsin.idv.tw\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wp.chunhsin.idv.tw\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wp.chunhsin.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3123"}],"version-history":[{"count":9,"href":"https:\/\/wp.chunhsin.idv.tw\/index.php?rest_route=\/wp\/v2\/posts\/3123\/revisions"}],"predecessor-version":[{"id":3132,"href":"https:\/\/wp.chunhsin.idv.tw\/index.php?rest_route=\/wp\/v2\/posts\/3123\/revisions\/3132"}],"wp:attachment":[{"href":"https:\/\/wp.chunhsin.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3123"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wp.chunhsin.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3123"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wp.chunhsin.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3123"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}