“Kasing sakelar PHP” Kode Jawaban

PHP huruf besar

//string to all uppercase
$string = "String with Mixed use of Uppercase and Lowercase";
//php string to uppercase
$string = strtoupper($string);
// = "STRING WITH MIXED USE OF UPPERCASE AND LOWERCASE"
Vic20

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 kasus di PHP


<?php
switch ($i) {
    case "apple":
        echo "i is apple";
        break;
    case "bar":
        echo "i is bar";
        break;
    case "cake":
        echo "i is cake";
        break;
}
?>

Fantastic Fly

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

Kasing sakelar PHP

<?php
if ($i == 0) {
    echo "i equals 0";
} elseif ($i == 1) {
    echo "i equals 1";
} elseif ($i == 2) {
    echo "i equals 2";
}

switch ($i) {
    case 0:
        echo "i equals 0";
        break;
    case 1:
        echo "i equals 1";
        break;
    case 2:
        echo "i equals 2";
        break;
}
?>
CodeExampler

Jawaban yang mirip dengan “Kasing sakelar PHP”

Pertanyaan yang mirip dengan “Kasing sakelar PHP”

Lebih banyak jawaban terkait untuk “Kasing sakelar PHP” di PHP

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya