> Le 26 mars 2020 à 19:37, Ilija Tovilo <ilija.tovilo@me.com> a écrit :
>
> What's the reasoning behind this? I find it weird an inconsistent.
>
This is a manifestly a leftover of an old syntax. Take a look at the PHP/FI 2 manual:
Language constructs:
https://www.php.net/manual/phpfi2.php#lang <https://www.php.net/manual/phpfi2.php#lang>
```
<?
if($a==5 && $b!=0 );
$c = 100 + $a / $b;
endif;
>
```
and, in particular, switch construct:
https://www.php.net/manual/phpfi2.php#switch <https://www.php.net/manual/phpfi2.php#switch>
```
<?
$a=0;
switch($a) {
case 1;
echo "a is 1";
break;
case "hello";
echo "a is hello";
break;
default;
echo "a is unknown";
break;
}
>
```
Note that every line of code, including `if (...);` and `case...;`, is consistently terminated by a semicolon.
In a subsequent major version, the syntax was modified, and you would use a colon instead of a semicolon in a number of places, as you can write today:
```
<?php
if ($a==5 && $b!=0):
$c = 100 + $a / $b;
endif;
>
```
Although the old `if (true);` syntax has been removed (probably because of ambiguity or difficulty of parsing), the old `case 1;` syntax could be left without issue.
—Claude