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

  1. <?php
  2. $operator = readline('Welke operatie wil je uitvoeren? (+, -, %) ' . PHP_EOL);
  3.  
  4. $getal_1 = readline("Eerste getal?" . PHP_EOL);
  5. $getal_2 = readline("Tweede getal?" . PHP_EOL);
  6.  
  7. if (!is_numeric($getal_1)) { 
  8.     exit("Het eerste getal was ongeldig!")
  9. } else if (!is_numeric($getal_2)) { 
  10.     exit("Het tweede getal is ongeldig!")
  11. } 
  12.  
  13.  
  14. ?>
File Description
  • calculator
  • PHP Code
  • 12 Sep-2021
  • 342 Bytes
You can Share it: