No Case With A Semi-colon¶
It was little known that one could use a semi-colon ; in a case entry, instead of a colon :. Both would act as a delimiter between the case value and the actualy case block.
Since PHP 8.5, it is forbidden.
PHP code¶
<?php
$a = 1;
switch ($a) {
case 1;
echo 2;
break;
}
?>
Before¶
2
After¶
PHP Deprecated: Case statements followed by a semicolon (;) are deprecated, use a colon (:) instead
Deprecated: Case statements followed by a semicolon (;) are deprecated, use a colon (:) instead
2
PHP version change¶
This behavior changed in 8.5