PHP: <?php if (isset($_POST['calc'])){ require_once "lib/function.php"; $n_1 = $_POST["n_1"]; $n_2 = $_POST["n_2"]; $operation = $_POST["operation"]; switch ($operation){ case="add"; $result = "$n_1 + $n_2 = ".add($n_1, $n_2); break case="sub"; $result = "$n_1 - $n_2 = ".sub($n_1, $n_2); break case="mult"; $result = "$n_1 * $n_2 = ".mult($n_1, $n_2); break case="div"; $result = div($n_1, $n_2); if ($result === false) $result = "Деление на ноль"; else $result = "$n_1 / $n_2 = ".add($n_1, $n_2); break } case="fact":{ $result = fact($n_1); if ($result === false) $result = "Факториала не существует"; else $result = "$n_1! = $fact"; break } default $result = "Неизвестная операция"; } ?> <!DOCTYPE html> <html lang="ru"> <head> <title>Калькулятор</title> </head> <body> <?php if (isset($result)) echo "<p>Вычисление $result</p>"; ?> <form name="myform" action="index.php" method="post"> <p> <input type="text" name="n_1" /> <select name="operation"> <?php $operation = array("add" => "+", "sub" => "-","mult" => "*","div" => "/","fact" => "!"); foreach ($operation as $key => $value){ echo "<option value='$key'>$value</option>"; } ?> </select> <input type="text" name="n_2" /> <br /> <input type="submit" name="calc" value="Вычислить" /> </p> </form> </body> </html>
а почему после case стоит знак равно? почему после кострукции case стоит точка с запятой? почему после break не стоит точка с запятой?))