如何在php/smarty中包含静态html

如何在php/smarty中包含静态html,php,html,include,smarty,Php,Html,Include,Smarty,我被要求在这个php/smarty页面中包含一些html片段。它基本上是一个销售协议,在你付款之前,放在概览页面的末尾 在php/smarty模板中包含静态html的代码是什么 谢谢 您的意思是包含包含静态HTML的文件吗 {include file=“htmlfile.html”} 编辑 由于文件只是HTML,因此最好使用,例如 对于本地文件,可以使用完整系统 必须指定文件路径,或指定路径 相对于已执行的php脚本 如果您试图包含一些包含javascript或类似内容的代码,可以使用 {l

我被要求在这个php/smarty页面中包含一些html片段。它基本上是一个销售协议,在你付款之前,放在概览页面的末尾

在php/smarty模板中包含静态html的代码是什么


谢谢

您的意思是包含包含静态HTML的文件吗

{include file=“htmlfile.html”}

编辑

由于文件只是HTML,因此最好使用,例如

对于本地文件,可以使用完整系统 必须指定文件路径,或指定路径 相对于已执行的php脚本


如果您试图包含一些包含javascript或类似内容的代码,可以使用
{literal}{/literal}
标记
要插入文件,可以使用Tom所说的
{include file=“htmlfile.html”}

在显示模板之前,在PHP文件中尝试以下操作:

$smarty->assign('Sectionfile','section-name.html');
$smarty->display('template.tpl');
在模板本身中:

{include file="html_dir/$Sectionfile"} 

与其他模板一样,smarty文件本身也是HTML文件。您可以将HTML粘贴到smarty模板中。

这就是我的意思。但它返回以下内容:
警告:Smarty error:无法读取/home/euroworkerno/www/library/Smarty/libs/Smarty.php中的资源:“custom:betalingsvilkar.html”,第1095行
函数trigger\u error($error\u msg,$error\u type=E\u USER\u Warning){trigger\u error(“Smarty error:$error\u msg,$error\u type)}
这是第1095行。致命错误:在/home/euroworkerno/www/application/controller/CheckoutController.php的第1354行对非对象调用成员函数assign(),这是我添加
$smarty->assign('Sectionfile','betalingsvillkar.html')时返回的$smarty->display('completeOverview.tpl')-我的php/smarty太差劲了。是的,这是我的第一个解决方案,在我看来也是最好的,因为这个文件只包含在一个页面中,但我的老板坚持要将它作为一个包含。
{include file="html_dir/$Sectionfile"}