I recently encountered the switch statement syntax error described at http://php.net/manual/en/control-structures.alternative-syntax.php

My IDE (phpstorm) detected the error, but it didn't provide any useful context for correction. The code certainly did produce a fatal error when including the file as a template.

The manual page's warning:

Warning Any output (including whitespace) between a switch statement and the first case will result in a syntax error. For example, this is invalid:

<?php switch ($foo): ?> <?php case 1: ?> ... <?php endswitch ?>

Whereas this is valid, as the trailing newline after the switch statement is considered part of the closing ?> and hence nothing is output between the switch and case:

<?php switch ($foo): ?> <?php case 1: ?> ... <?php endswitch ?>

The manual page offers no explanation. Some user comments on the page don't explain anything either; they simply restate that whitespace isn't allowed.

Why is this a syntax error?