welcome to tutorialfamily

php switch

PHP switch – used for check various cases.

When case match found code executed.


Switch statement

First of create a variable.

Stote the value in variable.

Get variable in switch statement.

Now check the case until match is not found.


Switch statement



<!DOCTYPE html>
<html>
<head>
	<title>Switch statement</title>
</head>
<body>
// Switch statement
<?php
 
$i = 'Toyota'; 
switch ($i)
{
    case "BMW":
        echo "is BMW";
        break;
    case "Toyota":
        echo "is expensive car";
        break;
    case "Hero":
        echo "is Bike";
        break;
}

?>							
</body>
</html>

output

Our Content