xref: /PHP-5.4/ext/json/tests/bug54058.phpt (revision bcc87ba6)
1--TEST--
2Bug #54058 (json_last_error() invalid UTF-8 produces wrong error)
3--SKIPIF--
4<?php if (!extension_loaded("json")) print "skip"; ?>
5--FILE--
6<?php
7
8$bad_utf8 = quoted_printable_decode('=B0');
9
10json_encode($bad_utf8);
11var_dump(json_last_error());
12
13$a = new stdclass;
14$a->foo = quoted_printable_decode('=B0');
15json_encode($a);
16var_dump(json_last_error());
17
18$b = new stdclass;
19$b->foo = $bad_utf8;
20$b->bar = 1;
21json_encode($b);
22var_dump(json_last_error());
23
24$c = array(
25    'foo' => $bad_utf8,
26    'bar' => 1
27);
28json_encode($c);
29var_dump(json_last_error());
30?>
31--EXPECTF--
32int(5)
33int(5)
34int(5)
35int(5)
36