web - what is causing this endforeach error when I try to upgrade the site to PHP 7.4?
one text
Solution:
It looks like the error is not from the version of PHP, but the configuration: you have the short_open_tag setting turned off on your new server/installation.
Since you have a mixture of short (<?) and full (<?php) tags here, if short tags is off, PHP will only be reading half of them. To PHP, the if, else, and second foreach simply don't exist (they'll be part of the output), so it's as though you'd written this:
<select size="1" class="<?php echo $this->level; ?> mobilenav" onchange="document.location.href = '/'+this.value">
<option value="">Navigation...</option>
<?php foreach ($this->items as $item):
$classes = explode(" ",$item["class"]);
?>
<optgroup label="<?= $item["link"] ?>">
<?= $item["subitems"] ?>
</optgroup>
<?php endforeach; ?>
<?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>
Source