If a is 0 , then equation is not quadratic , but linear
if ( $ a == 0 ) { echo " Invalid " ; return ; } $ d = $ b * $ b - 4 * $ a * $ c ; $ sqrt_val = sqrt ( abs ( $ d ) ) ; if ( $ d > 0 ) { echo " Roots ▁ are ▁ real ▁ and ▁ " . " different ▁ STRNEWLINE " ; echo ( - $ b + $ sqrt_val ) / ( 2 * $ a ) , " STRNEWLINE " , ( - $ b - $ sqrt_val ) / ( 2 * $ a ) ; } else if ( $ d == 0 ) { echo " Roots ▁ are ▁ real ▁ and ▁ same ▁ STRNEWLINE " ; echo - $ b / ( 2 * $ a ) ; }