Created
September 26, 2014 00:22
-
-
Save JustinSainton/cb0067802b9b96fc7e57 to your computer and use it in GitHub Desktop.
json msg
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| if (!function_exists('json_last_error_msg')) { | |
| function json_last_error_msg() { | |
| static $errors = array( | |
| JSON_ERROR_NONE => null, | |
| JSON_ERROR_DEPTH => 'Maximum stack depth exceeded', | |
| JSON_ERROR_STATE_MISMATCH => 'Underflow or the modes mismatch', | |
| JSON_ERROR_CTRL_CHAR => 'Unexpected control character found', | |
| JSON_ERROR_SYNTAX => 'Syntax error, malformed JSON', | |
| JSON_ERROR_UTF8 => 'Malformed UTF-8 characters, possibly incorrectly encoded' | |
| ); | |
| $error = json_last_error(); | |
| return array_key_exists($error, $errors) ? $errors[$error] : "Unknown error ({$error})"; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment