Switch Case and alternative syntax in html

I seems like whitespaces are not allowed in switch alternative syntax.
This makes it hard to keep proper indented code when using php as a “template engine”

<?php ?>
	<?php switch ($i): ?>

		<?php case 1: ?>
			<div>HTML</div>
		<?php break; ?>

		<?php case 2: ?>
			<div>Other HTML</div>
		<?php break; ?>

	<?php endswitch; ?>
<?php ?>

This will output
Parse error: syntax error, unexpected T_INLINE_HTML, expecting T_ENDSWITCH or T_CASE or T_DEFAULT

Do i have to use if statements to solve this, or do you guys have any other solutions rather than having to break my nicely indented code :slight_smile:

Need to use the switch statement properly
http://ca3.php.net/switch[http://ca3.php.net/switch](http://ca3.php.net/switch)

<?php ?>
    <?php switch ($i) { ?>

        <?php case 1: ?>
            <div>HTML</div>
        <?php break; ?>

        <?php case 2: ?>
            <div>Other HTML</div>
        <?php break; ?>

    <?php } ?>
<?php ?>

ok too bad :frowning:
using the alternative syntax everywhere else in my code so the alternative syntax would be nice for switch too, sucks :slight_smile:

Thanks anyway

Inline html (everything between ?> and <?php) is syntactically the same as operator, and there are no operators allowed between ‘switch’ and first ‘case’.