json_last_error_msg

(PHP 5 >= 5.5.0, PHP 7)

json_last_error_msgReturns the error string of the last json_encode() or json_decode() call

Описание

string json_last_error_msg ( void )

Список параметров

У этой функции нет параметров.

Возвращаемые значения

Returns the error message on success, "No Error" if no error has occurred, или FALSE в случае возникновения ошибки.

Смотрите также

Коментарии

Автор:
Here's an updated version of the function:

<?php
   
if (!function_exists('json_last_error_msg')) {
        function 
json_last_error_msg() {
            static 
$ERRORS = array(
               
JSON_ERROR_NONE => 'No error',
               
JSON_ERROR_DEPTH => 'Maximum stack depth exceeded',
               
JSON_ERROR_STATE_MISMATCH => 'State mismatch (invalid or malformed JSON)',
               
JSON_ERROR_CTRL_CHAR => 'Control character error, possibly incorrectly encoded',
               
JSON_ERROR_SYNTAX => 'Syntax error',
               
JSON_ERROR_UTF8 => 'Malformed UTF-8 characters, possibly incorrectly encoded'
           
);

           
$error json_last_error();
            return isset(
$ERRORS[$error]) ? $ERRORS[$error] : 'Unknown error';
        }
    }
?>
2015-06-03 12:34:14
http://php5.kiev.ua/manual/ru/function.json-last-error-msg.html

    Поддержать сайт на родительском проекте КГБ