switch statement checks one value against multiple cases — it's great for handling things like roles, statuses, selected menu items, or payment states.
php
<?php
$status = "paid";
switch ($status) {
case "pending":
echo "Payment is still pending.";
break;
case "paid":
echo "Payment received. Prepare the order.";
break;
case "cancelled":
echo "Order was cancelled.";
break;
default:
echo "Unknown payment status.";
}
?>You should see
Payment received. Prepare the order.