A switch Statement for string : Switch : Language Basics PHP Source Code


PHP Source Code » Language Basics » Switch »

 

A switch Statement for string



<html>
<head>
<title>A switch Statement</title>
</head>
<body>
<?php
$mood = "sad";
switch $mood ) {
    case "happy":
        print "I'm in a good mood";
        break;
    case "sad":
        print "Don't be down!";
        break;
    default:
        print "Neither happy nor sad but $mood";
}
?>
</body>
</html>

           
       



HTML code for linking to this page:

    PHP Function Reference -> Users Code Examples / Notes - > Switch:
  • switch
Follow Navioo On Twitter

PHP Source Code

 Navioo Language Basics
» Switch