Skip to content

Latest commit

 

History

History
41 lines (34 loc) · 637 Bytes

DuplicateCaseCondition.md

File metadata and controls

41 lines (34 loc) · 637 Bytes

DuplicateCaseCondition

In switch statement, when duplicate case conditions are included, the later is ignored.

Before

<?php
switch ($a) {
    case 1:
        echo "hoge";
        break;
    case 1: // DuplicateCaseCondition: Duplicate case condition found.
        echo "fuga";
        break;
    default:
        echo "meow";
        break;
}

After

<?php
switch ($a) {
    case 1:
        echo "hoge";
        break;
    case 2: // OK!
        echo "fuga";
        break;
    default:
        echo "meow";
        break;
}

Reference

https://secure.php.net/manual/en/control-structures.switch.php