You have two errors.
First one is mathematical, it should be
$ans1 = ((-$x) + (sqrt(pow($x, 2) - (4 * $xsqrd * $num)))) / (2 * $xsqrd);
$ans2 = ((-$x) - (sqrt(pow($x, 2) - (4 * $xsqrd * $num)))) / (2 * $xsqrd);
Correct formula is (-b+-sqrt(b^2-4ac))/(2a)
instead of -b+sqrt(b^2-4ac)/(2a)
- in the latter case division would have priority over addition without parenthesis.
And second one is the way you output your result, you should use concatenation operator .
print "x = " . $ans1 . "," . $ans2;
(though I would use echo
instead of print
)