Answers for "switch case php"

PHP
17

switch case php

switch (fruit) {
  case apple:
    code to be executed if fruit=apple;
    break;
  case banana:
    code to be executed if fruit=banana;
    break;
    ...
  default:
    code to be executed if fruit is different from all fruits;
}
Posted by: Guest on December-29-2020
21

php switch

$age=20;
switch ($age) {
	case 19:
        echo "Age is 18";
        break;
    case 20:
        echo "Age is 20";
        break;
    case 21:
        echo "Age is 21";
        break;
}
Posted by: Guest on July-01-2019
6

switch case php

$fruit = "apple";
switch ($fruit) {
  case "apple":
    echo "doctor";
    break;
  case "banana":
    echo "monkey";
    break;
  default:
   	echo "things";
}//doctor
Posted by: Guest on January-19-2021
9

switch php

switch ($element) {
    case 0:
        echo "i es igual a 0";
        break;
    case 1:
        echo "i es igual a 1";
        break;
    case 2:
        echo "i es igual a 2";
        break;
}
Posted by: Guest on May-23-2020
1

switch case php

<?php

$fav_food = "burger";

switch($fav_food)
{
    case "pavbhaji":
        echo "My favourite food is pavbhaji";
        break;

    case "dhosa":
        echo "My favourite food is dhosa";
        break;

    case "dabeli":
        echo "My favourite food is dabeli";
        break;
    
    case "burger":
        echo "my favourite food is burger";
        break;

    default:
        echo "I am foody..";
        break;
}
?>
Posted by: Guest on September-06-2021
0

switch case php

<?php
switch ($i) {
    case "apple":
        echo "i is apple";
        break;
    case "bar":
        echo "i is bar";
        break;
    case "cake":
        echo "i is cake";
        break;
}
?>
Posted by: Guest on September-21-2021

Browse Popular Code Answers by Language