switch statement and multiple default cases

[email protected] ("Robert Stoll")
Newsgroups php.standards
Message-ID <[email protected]>
Heya,

 

The spec states "There must be at most one default label." [1] which is
surely the right way to go IMO but not even the PHP implementation (5.5.9)
behaves like this and the following is perfectly valid:

 

$a=1;

$b=0;

switch($a) {

  default:

    $b += 1;

    break;

  default:

    $b += 2;

}

echo $b; //output would be 2

 

Should I report a bug?

 

Cheers,

Robert

 

[1]
<https://github.com/php/php-langspec/blob/master/spec/11-statements.md#the-s
witch-statement>
https://github.com/php/php-langspec/blob/master/spec/11-statements.md#the-sw
itch-statement
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.