意想不到的终结线34不知道为什么

时间:2014-12-02 09:32:30

标签: 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;?>

1 个答案:

答案 0 :(得分:3)

更改

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

为:

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

Reference

说明:

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

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

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

相关问题