dimanche 4 juin 2017

Syntax error: PHP brackets issue for IF and FOREACH?

<?php if (count($errors) > 0): ?>
  <div class="error">
     <?php foreach ($errors as $error) ?>
     <p><?php echo $error; ?></p>
  <?php endforeach ?>
  </div>
<?php endif ?>

My apologies if this is obvious to some of you more experienced PHP developers, but my code has the following errors;

"ForEach must uses braces"

AND

"Unexpected endforeach after string"

I know that these { braces should inserted somewhere, but I'm not sure where and in what order? Also, what do I need to do after the string in question?

Any help would be much appreciated. Thanks.

Aucun commentaire:

Enregistrer un commentaire