What potential issues can arise when passing variables in PHP using a switch statement?

When passing variables in PHP using a switch statement, one potential issue that can arise is not handling default cases. If the variable being switched on does not match any of the cases, the default case will not be executed, leading to unexpected behavior. To solve this issue, always include a default case in the switch statement to handle any unmatched cases.

$variable = "option1";

switch ($variable) {
    case "option1":
        echo "Option 1 selected";
        break;
    case "option2":
        echo "Option 2 selected";
        break;
    default:
        echo "Invalid option selected";
        break;
}