意外的 endif 第 34 行不知道为什么

  • 本文关键字:不知道 endif 意外 php
  • 更新时间 :
  • 英文 :


解析错误意外的结束如果在我不知道为什么的行

   <form name="contactform" method="post" action="check.php" class="form-horizontal" role="form">
                        <?php   if(array_key_exists('errors', $_SESSION));   ?>
                     <div class="alert alert-danger">
                        <?php implode('<br>', $_SESSION['errors']); ?>
                     </div>
                    <?php unset($_SESSION['errors']); ?>
                <?php endif;?>

更改

<?php   if(array_key_exists('errors', $_SESSION));   ?>

自:

<?php   if(array_key_exists('errors', $_SESSION)):   ?>

参考

解释:

在您的代码中,您将分号;放在 if 语句之后。

这意味着您正在关闭if控制结构,因此,下面的endif没有任何意义。

如果你放:ifendif之间的代码将被视为控制结构的主体,因此不会产生错误。

最新更新