04 - 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 04.php
- <?php
- function json_error_message($json_str)
- {
- $json[] = $json_str;
- echo $json;
- foreach ($json as $string)
- {
- echo 'Decoding: ' . $string."\n";
- json_decode($string);
- switch (json_last_error())
- {
- case JSON_ERROR_NONE:
- echo ' - No errors'."\n";
- break;
- case JSON_ERROR_DEPTH:
- echo ' - Maximum stack depth exceeded'."\n";
- break;
- case JSON_ERROR_STATE_MISMATCH:
- echo ' - Underflow or the modes mismatch'."\n";
- break;
- case JSON_ERROR_CTRL_CHAR:
- echo ' - Unexpected control character found'."\n";
- break;
- case JSON_ERROR_SYNTAX:
- echo ' - Syntax error, malformed JSON'."\n";
- break;
- case JSON_ERROR_UTF8:
- echo ' - Malformed UTF-8 characters, possibly incorrectly encoded'."\n";
- break;
- default:
- echo ' - Unknown error'."\n";
- break;
- }
- }
- }
- json_error_message('{"color1": "Red Color"}');
- ?>
File Description
- 04
- PHP Code
- 25 Jan-2024
- 777 Bytes
You can Share it:
Latest PHP Pastes