Search This Blog

switch in php

<?php

$input="1";

switch($input)
{
case 1       : echo 'one';
break;

case 2       : echo 'two';
break;

case 3       : echo 'three';
break;

case 4       :echo 'four';
break;

case 5       : echo 'five';
break;

case 'hello' : echo 'hello how are you?';
break;

default:
echo '<b>required number or string is not found</b>';
break;
}
?>

output :
one
=============================================

input : 2
output: two


input :3
output:three

input :4
output:four

input : hello
output: hello how are you?



Share Links

Related Posts Plugin for WordPress, Blogger...