4.3 - PHP Online

Form of PHP Sandbox

Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php in the places where the PHP script should be executed.



Your result can be seen below.

Result of php executing





Full code of 4.3.php

  1. <?php
  2. $a = 1;
  3. $b = -5;
  4. $c = 6;
  5.  
  6. $D = $b * $b - 4 * $a * $c;
  7.  
  8. if ($D > 0) {
  9.     $x1 = (-$b + sqrt($D)) / (2 * $a);
  10.     $x2 = (-$b - sqrt($D)) / (2 * $a);
  11.     echo "Уравнение имеет два корня: x1 = $x1, x2 = $x2";
  12. } elseif ($D == 0) {
  13.     $x1 = $x2 = -$b / (2 * $a);
  14.     echo "Уравнение имеет один корень: x1 = x2 = $x1";
  15. } else {
  16.     echo "Уравнение не имеет действительных корней";
  17. }
  18. ?>
File Description
  • 4.3
  • PHP Code
  • 07 Jun-2023
  • 467 Bytes
You can Share it: