karlakmkj

switch case stm

Sep 17th, 2021
640
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. namespace Codecademy;
  3.  
  4. function airQuality($color){
  5.   switch ($color){
  6.     case "green":
  7.       echo "good";
  8.       break;
  9.     case "yellow":
  10.       echo "moderate";
  11.       break;
  12.     case "orange":
  13.       echo "unhealthy for sensitive groups";
  14.       break;
  15.     case "red":
  16.       echo "unhealthy";
  17.       break;
  18.     case "purple":
  19.       echo "very unhealthy";
  20.       break;
  21.     case "maroon":
  22.       echo "hazardous";
  23.       break;
  24.     default:
  25.       echo "invalid color";
  26.   }
  27. }
  28.  
  29. // test with different arguments
  30. airQuality("pink");
  31. echo "\n\n";
  32. airQuality("purple");
  33. echo "\n\n";
  34. airQuality("green");  
RAW Paste Data