// Тернарный оператор $a = ($b>5 ? $x : $y); // С фигурными скобками if ($a > $b) { echo "a is bigger than b"; } else if ($a == $b) { echo "a is equal to b"; } else { echo "a is smaller than b"; } // В стиле Python if ($a > $b): echo $a." is greater than ".$b; elseif ($a == $b): echo $a." equals ".$b; else: echo $a." is neither greater or equal to ".$b; endif; // Оператор switch switch ($i) { case 0: case 1: echo "i equals 0 or 1"; break; case 2: echo "i equals 2"; break; default: echo "i equals 3"; }
PHP Справочник v0.05 © 2007-2024 Igor Salnikov aka SunDoctor