Answers for "php contains string with switch statement"

PHP
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
0

is switch case case sensitive in php

<?php
$smart = "cRikEy";

switch (strtolower($smart)) {
     case "crikey": // Note the lowercase chars
         echo "Crikey";
         break;
     case "hund":
         echo "Hund";
         break;
     case "kat":
         echo "Kat";
         break;
     default:
         echo "Alt Andet";
}
?>
Posted by: Guest on April-28-2021

Code answers related to "php contains string with switch statement"

Browse Popular Code Answers by Language