essa - 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 essa.php

  1. <html>
  2. <head>
  3. <body>
  4. <form method="POST" action="">
  5. <input type="text" name="liczba1" size="10">
  6. <select name="znak">
  7. <option>+</option>
  8. <option>-</option>
  9. <option>*</option>
  10. <option>/</option>
  11. </select>
  12. <input type="text" name="liczba2" size="10">
  13. <input type="submit" value="Oblicz">
  14. </form>
  15. <?php
  16. $liczba1 = $_POST['liczba1'];
  17. $liczba2 = $_POST['liczba2'];
  18. $znak = $_POST['znak'];
  19. $wynik = "";
  20. switch ($znak)
  21. {
  22.  case "+":
  23.    $wynik = $liczba1+$liczba2;
  24.    break;
  25.  case "-":
  26.    $wynik = $liczba1-$liczba2;
  27.    break;
  28.  case "*":
  29.    $wynik = $liczba1*$liczba2;
  30.    break;
  31.  case "/":
  32.    $wynik = $liczba1/$liczba2;
  33.    break;
  34. }
  35. echo $wynik;
  36. ?>
  37. </body>
  38. </head>
  39. </html>
  40.  
File Description
  • essa
  • PHP Code
  • 15 Feb-2021
  • 664 Bytes
You can Share it: