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.
Result of php executing
Full code of calculator.php
- <?php
- $operator = readline("Welke operatie wil je uitvoeren (+ , - , %)?" . PHP_EOL);
- $op1 = "+";
- $op2 = "-";
- $op3 = "%";
- $getal_1 = readline("Eerste getal?" . PHP_EOL);
- $getal_2 = readline("Tweede getal?" . PHP_EOL);
- if ($operator === $op1) {
- echo "De som van " . $getal_1 . " en "
- . $getal_2 . " is " . ($getal_1 + $getal_2);
- } else if ($operator === $op2) {
- echo "De deviatie van " . $getal_1 . " en "
- . $getal_2 . " is " . ($getal_1 - $getal_2);
- } else {
- echo "De deviatie van " . $getal_1 . " en "
- . $getal_2 . " is " . ($getal_1 - $getal_2);
- }
- if (!is_numeric($getal_1)) {
- exit("/geen (getal|nummer)/);
- } else if (!is_numeric($getal_2)) {
- exit("/geen (getal|nummer)/);
- }
- ?>
File Description
- calculator
- PHP Code
- 12 Sep-2021
- 722 Bytes
You can Share it:
Latest PHP Pastes