在回声

时间:2016-04-16 12:18:57

标签: php html

因此PHPStorm在以下行之后给出了“期待语句”错误:

echo $values;

以下是代码中的部分:

<?php
            if(!empty($_POST)){
                $values = implode(', ', array_intersect_key($_POST, $boxes));
                $txt = $_POST['Zoeken'];
                echo $values;
                ​
                ?>
                <br>
                <?php
                echo $txt;
            }
            ?>

这是完整的代码(表单):

<div id="filterList">
        <?php $boxes = [
            'first_name' => ['label' => 'Voornaam', 'value' => 'a_Voornaam'],
            'last_name' => ['label' => 'Achternaam', 'value' => 'a_Achternaam'],
            'address' => ['label' => 'Adres', 'value' => 'a_Adres'],
            'city' => ['label' => 'Plaats', 'value' => 'a_Woonplaats'],
            'zipcode' => ['label' => 'Postcode', 'value' => 'a_Postcode'],
        ]; ?>
        <form name="filter"  style="float:left;" method="post">
            <table>
                <?php foreach ($boxes as $name => $box) { ?>
                    <tr>
                        <td>
                            <label><?php echo $box['label']; ?>:</label>
                        </td>
                        <td>
                            <input type="checkbox" name="<?php echo $name; ?>" id="inh" value="<?php echo $box['value']; ?>"/>
                        </td>
                    </tr>
                <?php } ?>
                <tr>
                    <td>
                        <label>Zoeken</label>
                    </td>
                    <td>
                        <input type="text" name="Zoeken" />
                    </td>
                </tr>
                <tr>
                    <td>
                        <label style="margin-top:5px;"></label>
                    </td>
                    <td>
                        <input id="submitfilter" type="submit" style="margin-top:5px;" class="btn"/>
                    </td>
                </tr>
            </table>
            <?php
            if(!empty($_POST)){
                $values = implode(', ', array_intersect_key($_POST, $boxes));
                $txt = $_POST['Zoeken'];
                echo $values;
                ​
                ?>
                <br>
                <?php
                echo $txt;
            }
            ?>
        </form>
</div>

错误的原因是什么?

1 个答案:

答案 0 :(得分:3)

当我复制/粘贴代码时,在所谓的空行中似乎有一个不可见的字符。

所以只需删除<-- odd character here

指示的空白行
        <?php
        if(!empty($_POST)){
            $values = implode(', ', array_intersect_key($_POST, $boxes));
            $txt = $_POST['Zoeken'];
            echo $values;
             <-- odd invisible character here             
            ?>
            <br>
            <?php
            echo $txt;
        }
        ?>