test - 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 test.php
- <?php
- if (isset($_POST['a'])) $string_a = htmlentities($_POST['a']);
- if (isset($_POST['b'])) $string_b = htmlentities($_POST['b']);
- $isEmpty = false;
- if ((empty($string_a)) || (empty($string_b))) $isEmpty = true;
- if (!$isEmpty) {
- $a = (int)$string_a;
- $b = (int)$string_b;
- $c = $a + $b;
- // Формируем JSON ответ от сервера
- $arr = array('a' => $a, 'b' => $b, 'c' => $c);
- echo json_encode($arr);
- }
- else {
- echo "error";
- }
- ?>
File Description
- test
- PHP Code
- 27 Jan-2023
- 460 Bytes
You can Share it:
Latest PHP Pastes