Re: Deprecate alternate switch case syntax?

From: Date: Thu, 21 Nov 2024 09:36:03 +0000
Subject: Re: Deprecate alternate switch case syntax?
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-126016@lists.php.net to get a copy of this message
Hi Am 2024-11-20 20:03, schrieb Derick Rethans:
All my PHP based templates for the xdebug.org site use this style. I don't think it's atrocious, and quite a bit nicer than the "new" syntax.
This proposal would not affect that. You would just need to add a colon after the case statement, not a semicolon. In fact that would more closely match the corresponding switch, which would also need to have a colon:
    <?php $foo = "bar"; ?>
    <?php
    switch ($foo):
    case "bar":
    ?>
    BAR
    <?php break; case "baz": ?>
    BAZ
    <?php endswitch; ?>
Though using switch in such templates is somewhat finicky anyway, because it will need to be merged with the first case, because otherwise:
Parse error: syntax error, unexpected T_INLINE_HTML "", expecting "endswitch" or "case" or "default"
Best regards Tim Düsterhus

« previous php.internals (#126016) next »