“sakelar php” Kode Jawaban

sakelar php

$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;
}
Grepper

Beralih PHP

switch ($element) {
    case 0:
        echo "i es igual a 0";
        break;
    case 1:
        echo "i es igual a 1";
        break;
    case 2:
        echo "i es igual a 2";
        break;
}
CharllierJr

Pernyataan sakelar PHP

<?php

  /*
  We use the switch statement to select any one of many blocks to be
  executed.
  Here is an example:
  */
switch (n) {
  case label1:
    code to be executed if n=label1;
    break;
  case label2:
    code to be executed if n=label2;
    break;
  case label3:
    code to be executed if n=label3;
    break;
    ...
  default:
    code to be executed if n is different from all labels;
}

  /*
  You assign it a variable.
  Here is an example of it being used
  */

  $polygon = 12

  switch ($polygon) {
  case 12:
    echo "Dodecagon";
    break;
  case 18:
    echo "Octadecagon";
    break;
  case 42:
    echo "Tetracontakaidigon";
    break;
  default:
    echo "Enneacontakaihexagon";
  }
?>
Rick Astley

array case switch php

foreach ($array[0] as $key => $value) {
    switch ($key) {
        case 'Products' :
            // do something
            break ;
        case 'customers' :
            // do something
            break ;
        case 'Models' :
            // do something
            break ;
     }
 }
Grevil

Pernyataan sakelar PHP

<?php
$favcolor = "red";

switch ($favcolor) {
  case "red":
    echo "Your favorite color is red!";
    break;
  case "blue":
    echo "Your favorite color is blue!";
    break;
  case "green":
    echo "Your favorite color is green!";
    break;
  default:
    echo "Your favorite color is neither red, blue, nor green!";
}
?>
naly moslih

Jawaban yang mirip dengan “sakelar php”

Pertanyaan yang mirip dengan “sakelar php”

Lebih banyak jawaban terkait untuk “sakelar php” di PHP

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya