php-src/ext/json/tests/bug69187.phpt
Jakub Zelenka f30503ce4e Fix incompatible JSON errors
This fixes differences in error codes with PHP 5 and 7.
The malformed UTF-8 and control character error codes are
now returned even in non-string context which makes it
the same as it was in PHP 5 json ext.
2015-06-28 18:09:10 +01:00

50 lines
825 B
PHP

--TEST--
Bug #69187 json_last_error return BC in PHP7
--SKIPIF--
<?php if (!extension_loaded("json")) print "skip"; ?>
--FILE--
<?php
var_dump(json_decode(NULL));
var_dump(json_last_error());
var_dump(json_decode(FALSE));
var_dump(json_last_error());
var_dump(json_decode(""));
var_dump(json_last_error());
var_dump(json_decode(0));
var_dump(json_last_error());
var_dump(json_decode(1));
var_dump(json_last_error());
var_dump(json_decode(TRUE));
var_dump(json_last_error());
json_decode("\xED\xA0\xB4");
var_dump(json_last_error());
json_decode("\x00");
var_dump(json_last_error());
json_decode("\"\xED\xA0\xB4\"");
var_dump(json_last_error());
json_decode("\"\x00\"");
var_dump(json_last_error());
?>
--EXPECT--
NULL
int(4)
NULL
int(4)
NULL
int(4)
int(0)
int(0)
int(1)
int(0)
int(1)
int(0)
int(5)
int(3)
int(5)
int(3)