我正在尝试将 Web 联系表单添加到使用 Smarty PHP 模板的网站。
我最初的尝试(如下)会产生一个空白网页。
.tpl 文件
{debug}
{extends file='toxtweet.tpl'}
{block name=body}
    <form action="" method="post">
    {foreach from=$formitems as key=name item=value}
        <label for={$name}>{$value}</label>
        <input type="text" name={$name} size="50"/>
    {/foreach}
    <input type="submit" value="E-mail" />
    </form>
{/block}
.php 文件
<?php
   include 'base.php';
   include './scripts/recaptchalib.php';
   $formitems = parse_ini_file("formitems.ini");
   $smarty -> assign('formitems',$formitems);
   $smarty -> display("contact.tpl");
 ?>
base.php并且toxtweet.tpl在所有其他页面上都可以正常工作,所以我认为它们不是问题。recaptchalib.php有正确的路径。
如果删除这些{foreach} ... {/foreach}行,空白网页将正常显示。如果我使用格式{foreach $x as $y}或{foreach from=$x key=k value=v}.
调试显示ini具有值的文件formitems已正确加载。