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
- $operation = readline(“Welke operatie wil je uitvoeren? (+, -, %)“);
- $op1 = "+";
- $op2 = "-";
- $op3 = "%";
- if ($operation == $op1) {
- $sum1 = $a + $b;
- echo (“Het resultaat is: ” . $sum1) . PHP_EOL;
- } elseif ($operation == $op2) {
- $sum2 = $a - $b;
- echo (“Het resultaat is: ” . $sum2) . PHP_EOL;
- } elseif ($operation == $op3) {
- $sum3 = $a % $b;
- echo (“Het resultaat is: ” . $sum3) . PHP_EOL;
- } else {
- exit(“geen geldige operatie” . PHP_EOL);
- }
- $a = readline(“Je eerste getal?” . PHP_EOL);
- if (!is_numeric($a)){
- } else {
- exit(“‘” . $a . “’ is geen getal” . PHP_EOL);
- }
- $b = readline(“Je tweede getal?” . PHP_EOL);
- if (!is_numeric($b)){
- } else {
- exit(“‘” . $b . “’ is geen getal” . PHP_EOL);
- }
- ?>
File Description
- calculator
- PHP Code
- 12 Sep-2021
- 785 Bytes
You can Share it:
Latest PHP Pastes