Hackerss.com

hackerss
hackerss

Posted on

Php Function can change color to the string


function changeColor($color) {
  switch ($color) {
    case 'red':
      echo 'color is red';
      break;
    case 'blue':
      echo 'color is blue';
      break;
    case 'green':
      echo 'color is green';
      break;
    default:
      echo 'color is not red, blue or green';
      break;
  }
}

//example
changeColor('red'); //color is red
changeColor('blue'); //color is blue
changeColor('green'); //color is green
changeColor('yellow'); //color is not red, blue or green



Enter fullscreen mode Exit fullscreen mode

Top comments (0)