簡體   English   中英

HTML模板文件中的PHP-Smarty Engine

[英]PHP in HTML-Template file - Smarty Engine

我目前正在使用Smarty PHP Engine。 現在,我想向模板文件中添加一點PHP代碼,如下所示:

{php}echo "asdf";{/php}

但是,當我打開瀏覽器時,出現此錯誤:

致命錯誤:模板中出現消息“語法錯誤”的未捕獲異常“ SmartyCompilerException”

似乎有什么問題,我該如何解決?

{php}echo("Hello, world!");{/php}

也許這可以代替嗎?

{php}
// including a php script directly from the template.
include('/path/to/display_weather.php');
{/php}

這樣,您可以將php代碼嵌入到smarty模板文件中。 檢查此內容以供參考http://www.smarty.net/docsv2/zh/language.function.php.tpl

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM