What are the common pitfalls when using switch case in PHP?

One common pitfall when using switch case in PHP is forgetting to include a break statement at the end of each case. This can cause the code to fall through to the next case unintentionally, leading to unexpected behavior. To solve this issue, remember to include a break statement at the end of each case to ensure that only the code within the matching case is executed.

$day = "Monday";

switch ($day) {
    case "Monday":
        echo "Today is Monday";
        break;
    case "Tuesday":
        echo "Today is Tuesday";
        break;
    case "Wednesday":
        echo "Today is Wednesday";
        break;
    default:
        echo "Invalid day";
}