reference/json/functions/json-last-error.xml
8cdc6621f9826d04abc3e50438c010804d7e8683
...
...
@@ -13,7 +13,8 @@
13
13
<void />
14
14
</methodsynopsis>
15
15
<para>
16
-
Returns the last error (if any) occurred during the last JSON encoding/decoding.
16
+
Returns the last error (if any) occurred during the last JSON encoding/decoding,
17
+
which did not specify <constant>JSON_THROW_ON_ERROR</constant>.
17
18
</para>
18
19
</refsect1>
19
20

...
...
@@ -67,12 +68,12 @@
67
68
<row>
68
69
<entry><constant>JSON_ERROR_UTF8</constant></entry>
69
70
<entry>Malformed UTF-8 characters, possibly incorrectly encoded</entry>
70
-
<entry>PHP 5.3.3</entry>
71
+
<entry></entry>
71
72
</row>
72
73
<row>
73
74
<entry><constant>JSON_ERROR_RECURSION</constant></entry>
74
75
<entry>One or more recursive references in the value to be encoded</entry>
75
-
<entry>PHP 5.5.0</entry>
76
+
<entry></entry>
76
77
</row>
77
78
<row>
78
79
<entry><constant>JSON_ERROR_INF_OR_NAN</constant></entry>
...
...
@@ -82,22 +83,22 @@
82
83
or <link linkend="function.is-infinite"><constant>INF</constant></link>
83
84
values in the value to be encoded
84
85
</entry>
85
-
<entry>PHP 5.5.0</entry>
86
+
<entry></entry>
86
87
</row>
87
88
<row>
88
89
<entry><constant>JSON_ERROR_UNSUPPORTED_TYPE</constant></entry>
89
90
<entry>A value of a type that cannot be encoded was given</entry>
90
-
<entry>PHP 5.5.0</entry>
91
+
<entry></entry>
91
92
</row>
92
93
<row>
93
94
<entry><constant>JSON_ERROR_INVALID_PROPERTY_NAME</constant></entry>
94
95
<entry>A property name that cannot be encoded was given</entry>
95
-
<entry>PHP 7.0.0</entry>
96
+
<entry></entry>
96
97
</row>
97
98
<row>
98
99
<entry><constant>JSON_ERROR_UTF16</constant></entry>
99
100
<entry>Malformed UTF-16 characters, possibly incorrectly encoded</entry>
100
-
<entry>PHP 7.0.0</entry>
101
+
<entry></entry>
101
102
</row>
102
103
</tbody>
103
104
</tgroup>
...
...
@@ -187,6 +188,31 @@ bool(true)
187
188
</screen>
188
189
</example>
189
190
</para>
191
+
<para>
192
+
<example>
193
+
<title><function>json_last_error</function> and <constant>JSON_THROW_ON_ERROR</constant></title>
194
+
<programlisting role="php">
195
+
<![CDATA[
196
+
<?php
197
+
// An invalid UTF8 sequence which causes JSON_ERROR_UTF8
198
+
json_encode("\xB1\x31");
199
+

200
+
// The following does not cause a JSON error
201
+
json_encode('okay', JSON_THROW_ON_ERROR);
202
+

203
+
// The global error state has not been changed by the former json_encode()
204
+
var_dump(json_last_error() === JSON_ERROR_UTF8);
205
+
?>
206
+
]]>
207
+
</programlisting>
208
+
&example.outputs;
209
+
<screen>
210
+
<![CDATA[
211
+
bool(true)
212
+
]]>
213
+
</screen>
214
+
</example>
215
+
</para>
190
216
</refsect1>
191
217

192
218
<refsect1 role="seealso">
193
219