Search code examples
cakephpphpstorm

Cake Php and PhpStorm Expecting statement


I have issue with ending foreach line in Php Storm (cake php 2.4.6)

This is my code in ctp file:

<h2>List Users</h2>

<table>
    <tr>
        <td>Name:</td>
        <td>Password:</td>
    </tr>
<?php foreach ($users  as $user); ?>

<tr>
    <td><?php echo $this->$user['User']['username'];?> </td>
    <td><?php echo $this->$user['User']['password'];?></td>
</tr>
    <?php endforeach ?>
</table>

On this line I have error:

<?php endforeach ?>  

(Expecting statement)

What is wrong with this ?


Solution

  • Foreach should start with colon :

    <?php foreach ($users  as $user): ?> //Should be colon not semi-colon
    
    <?php endforeach ?>
    

    Reference.