в чем ошибка Код (Text): <?php if (isset($_POST["calc"])){ require_once "lib/functions.php"; $n_1=$_POST["n_1"]; $n_2=$_POST["n_2"]; $operation=$_POST["operation"]; switch ($operation){ case "add": $result=add(n_1,n_2); break; case "sub": $result=sub(n_1,n_2); break; case "mult": $result=mult(n_1,n_2); break; case "div": { $result=div(n_1,n_2); if ($result===false) $result="error"; else $result=$result; break; } case "fact": { $result=factorial(n_1); if ($result===false) $result="error"; else $result=$fact; break; } default: $result="uncnown operation"; } } ?> <head> <title> Загаловок</title> </head> <body> <?php if (isset($result)) echo "<p> reult: $result </p>"; ?> <form name="myform" action="index.php" method="post"> <p> <input type="text" name="n_1" /> <select name="operation" > <?php $operations=array("add"=>"+","sub"=>"-","mult"=>"*","div"=>"/","fact"=>"!"); foreach($operations as $key => $value){ echo "<option value='$key'>$value</option>"; } ?> </select> <input type="text" name="n_2" /> </br> <input type="submit" name="calc" value="Vichislit" /> </p> </form> </body> </html>
выдает ошибку: Notice: Use of undefined constant n_1 - assumed 'n_1' in Z:\home\test.local\www\index.php on line 11 [Денвер: показать возможную причину ошибки] Notice: Use of undefined constant n_2 - assumed 'n_2' in Z:\home\test.local\www\index.php on line 11
На 11 строчке файла Z:\home\test.local\www\index.php не определённая константа n_1 Вам нужно понять как объявлять переменные и присваивать им значения Вот по переменным http://php.ru/manual/language.variables.basics.html
Исправьте $result=add(n_1,n_2); на $result=add($n_1,$n_2); и т.д. (переменные в PHP начинаются с символа $)