mardi 27 juillet 2021

what is causing this endforeach error when I try to upgrade the site to PHP 7.4?

Hey This code of mine is causing a total crash on my website:

<select size="1" class="<?php echo $this->level; ?> mobilenav" onchange="document.location.href = '/'+this.value">

<?
if(/*$this->level == "level_1"*/ false) {
?>
    <option value="">Navigation...</option>
<?php foreach ($this->items as $item): 
  
    $classes = explode(" ",$item["class"]); 

    ?>

      <optgroup label="<?= $item["link"] ?>">
          <?= $item["subitems"] ?>
      </optgroup>
  <?php endforeach; ?>
<?
} else {
    foreach ($this->items as $item):

        $classes = explode(" ",$item["class"]);

        ?>
        <?php if ($item['isActive'] || in_array("trail",$classes)): ?>
        <option class="<?php echo $item['class']; ?>" selected="selected"><span class="<?php echo $item['class']; ?>"><?php echo $item['link']; ?></span></option>
    <?php else: ?>
        <option<?php if ($item['class']): ?> class="<?php echo $item['class']; ?>"<?php endif; ?> value="<?php echo $item['href']; ?>"><?php echo $item['link']; ?></option>
    <?php endif; ?>
    <?php endforeach;
}?>
</select>

Story: im Upgrading an old Website of mine currently to be able to use it with the newest version of PHP.

This is the error im getting:

[2021-07-27 08:08:38] request.CRITICAL: Uncaught PHP Exception ParseError: "syntax error, unexpected 'endforeach' (T_ENDFOREACH), expecting end of file" at /var/www/vhosts/web/templates/nav_dropdown.html5 line 20 {"exception":"[object] (ParseError(code: 0): syntax error, unexpected 'endforeach' (T_ENDFOREACH), expecting end of file at /var/www/vhosts/web/templates/nav_dropdown.html5:20)"} []

I dont get why it is expecting the code to end at line 20, maybe someone has a fast answer for me? thanks in advance. Hans.




Aucun commentaire:

Enregistrer un commentaire