0
a、b、cをフォームで与えた単純多項式(x^2 + b x + c)を解くことが必要なラボプロジェクトがあります。私はこのコードを実装しましたが、htmlスクリプトでさえ動作していないようです。私は本当にあなたの助けが必要です。なぜなら、間違いを見つけようと一日を費やしていたからです。間違ったことは見つけられません。PHPの三項方程式ソルバー
<!DOCTYPE html>
<html>
<meta charset="utf-8"/>
<head>
<title>
Exercise 2
</title>
</head>
<body>
<? if ((!isset($_POST['submit'])))
{?>
<h2>Please fill the trinomial coefficients a*x^2+b*x+c=0</h2> <br>
<form method="post">
a= <input type="text" name="a" /> <br>
b= <input type="text" name="b" /> <br>
c= <input type="text" name="c" /> <br>
<input type="submit" value="Solve the equation" />
</form>
<?php
}
else
{
$a=$_POST["a"];
$b=$_POST["b"];
$c=$_POST["c"];
if ($a!=0)
{
$d=pow($b,2)-(4*a*c);
if ($d>=0)
{
$d=sqrt($d);
x1=(-$b-$d)/(2*$a);
x2=(-$b+$d)/(2*$a);
if (x1=x2)
{
echo ("1 solution: ". $x1);
}
else
{
echo ("Solutions x1 and x2 " .$x1. ", ". $x2);
}
}
else
{
$d=sqrt(-$d);
x1=-b/(2*$a);
x2=-$d;
x3=$d;
echo ("The trinomial has two complex solutions x1 and x2, which are: x1=". x1. " + ". x2. "*i and x2=". x1. " + ". x3. "*i");
}
}
else
{
echo ("This is not a trinomial");
}
}
?>
</body>
</html>