閲嶈璇存槑
Smarty宸茬粡搴熷純{php}
鏍囩锛屽己鐑堝缓璁笉瑕佷娇鐢ㄣ
璇锋妸浣犵殑PHP閫昏緫鏀惧埌PHP绋嬪簭鎴栬呮彃浠跺嚱鏁颁腑瀹炵幇銆
Note
鍦⊿marty 3.1锛{php}
浠呭湪SmartyBC涓彲鐢ㄣ
{php}
鏍囩鍙互鍏佽PHP浠g爜鐩存帴宓屽埌妯℃澘涓娇鐢ㄣ
杩欎簺浠g爜鏄惁琚紪鐮侊紝闇瑕佸彇鍐充簬$php_handling
鐨勮缃.
Example聽7.61.聽{php}鏍囩鐨勪娇鐢
{php} // including a php script directly from the template. include('/path/to/display_weather.php'); {/php}
Example聽7.62.聽{php}鏍囩涓娇鐢ㄥ叏灞鍙橀噺鏉ヨ祴鍊煎彉閲
{* this template includes a {php} block that assign's the variable $varX *} {php} global $foo, $bar; if($foo == $bar){ echo 'This will be sent to browser'; } // assign a variable to Smarty $this->assign('varX','Toffee'); {/php} {* output the variable *} <strong>{$varX}</strong> is my fav ice cream :-)
鍙傝
$php_handling
,
{include_php}
,
{include}
,
{insert}
鍜
缁勪欢鍖栨ā鏉.