“cas de commutateur PHP” Réponses codées

php majuscule

//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

interrupteur 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

Commutation 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

Déclaration de cas en 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

Instruction de commutation 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

cas de commutateur 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

Réponses similaires à “cas de commutateur PHP”

Questions similaires à “cas de commutateur PHP”

Plus de réponses similaires à “cas de commutateur PHP” dans PHP

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code