Tell me how to display the result of the code? Where do I need to prescribe echo or something else and how to attach the button <p><input type="submit" value=Посчитать> </p>
to make it work?
<? function square_roots($a, $b, $c) { if ($a == 0) return false; if ($b == 0) { if ($c < 0) { $x1 = sqrt(abs($c / $a)); $x2 = sqrt(abs($c / $a)); } elseif ($c == 0) { $x1 = $x2 = 0; } else { $x1 = sqrt($c / $a) . 'i'; $x2 = -sqrt($c / $a) . 'i'; } } else { $d = $b * $b - 4 * $a * $c; if ($d > 0) { $x1 = (-$b + sqrt($d)) / 2 * $a; $x2 = (-$b - sqrt($d)) / 2 * $a; } elseif ($d == 0) { $x1 = $x2 = (-$b) / 2 * $a; } else { $x1 = -$b . '+' . sqrt(abs($d)) . 'i'; $x2 = -$b . '-' . sqrt(abs($d)) . 'i'; } } return array( $x1, $x2 ); } ?>
-
<html> <head> <title>Решение квадратного уравнения </title> </head> <body> <table cellspacing="0" style="width:100%"> <p>Введите a: <input type="text" name="val1" size=10></p> <p>Введите b: <input type="text" name="val2" size=10></p> <p>Введите c: <input type="text" name="val3" size=10></p> <p><input type="submit" value=Посчитать> </p> </table> </body> </html>