/
vshmidt
/
php
Обзор
Документация
Войти
/
vshmidt
/
php
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
ext/json/tests/json_exceptions_error_clearing.phpt
48 строк
970 B
Tyson Andre
Clean up calls to extension_loaded('json') in tests
28 май 2020, 22:07
28 май 2020, 22:07
32a1ebb
Код
Авторство
О чём код?
--TEST-- JSON_THROW_ON_ERROR: global error flag untouched --FILE-- <?php var_dump(json_last_error()); // here we cause a different kind of error to the following errors, so that // we can be sure the global error state looking unchanged isn't coincidence json_decode("\xFF"); var_dump(json_last_error()); try { json_decode("", false, 512, JSON_THROW_ON_ERROR); } catch (JsonException $e) { echo "Caught JSON exception: ", $e->getCode(), PHP_EOL; } var_dump(json_last_error()); try { json_decode("{", false, 512, JSON_THROW_ON_ERROR); } catch (JsonException $e) { echo "Caught JSON exception: ", $e->getCode(), PHP_EOL; } var_dump(json_last_error()); try { json_encode(NAN, JSON_THROW_ON_ERROR); } catch (JsonException $e) { echo "Caught JSON exception: ", $e->getCode(), PHP_EOL; } var_dump(json_last_error()); ?> --EXPECT-- int(0) int(5) Caught JSON exception: 4 int(5) Caught JSON exception: 4 int(5) Caught JSON exception: 7 int(5)