Reputation: 6915
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 ?
Upvotes: 0
Views: 6106
Reputation: 26431
Foreach should start with colon :
<?php foreach ($users as $user): ?> //Should be colon not semi-colon
<?php endforeach ?>
Upvotes: 7
Reputation: 6654
You have put a semicolon here
<?php foreach ($users as $user); ?>
but it should be a colon:
<?php foreach ($users as $user): ?>
The semicolon ends the whole loop in this line.
Upvotes: 3