php-doc-en/reference/json/constants.xml
Christoph Michael Becker d6d7fb6e14 documented JSON_PARTIAL_OUTPUT_ON_ERROR
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@337480 c90b9560-bf6c-de11-be94-00142212c4b1
2015-08-15 14:34:32 +00:00

313 lines
8.3 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<appendix xml:id="json.constants" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
&reftitle.constants;
&extension.constants;
<para>
The following constants indicate the type of error returned by
<function>json_last_error</function>.
</para>
<variablelist>
<varlistentry xml:id="constant.json-error-none">
<term>
<constant>JSON_ERROR_NONE</constant>
(<type>integer</type>)
</term>
<listitem>
<simpara>
No error has occurred.
Available since PHP 5.3.0.
</simpara>
</listitem>
</varlistentry>
<varlistentry xml:id="constant.json-error-depth">
<term>
<constant>JSON_ERROR_DEPTH</constant>
(<type>integer</type>)
</term>
<listitem>
<simpara>
The maximum stack depth has been exceeded.
Available since PHP 5.3.0.
</simpara>
</listitem>
</varlistentry>
<varlistentry xml:id="constant.json-error-state-mismatch">
<term>
<constant>JSON_ERROR_STATE_MISMATCH</constant>
(<type>integer</type>)
</term>
<listitem>
<simpara>
Occurs with underflow or with the modes mismatch.
Available since PHP 5.3.0.
</simpara>
</listitem>
</varlistentry>
<varlistentry xml:id="constant.json-error-ctrl-char">
<term>
<constant>JSON_ERROR_CTRL_CHAR</constant>
(<type>integer</type>)
</term>
<listitem>
<simpara>
Control character error, possibly incorrectly encoded.
Available since PHP 5.3.0.
</simpara>
</listitem>
</varlistentry>
<varlistentry xml:id="constant.json-error-syntax">
<term>
<constant>JSON_ERROR_SYNTAX</constant>
(<type>integer</type>)
</term>
<listitem>
<simpara>
Syntax error.
Available since PHP 5.3.0.
</simpara>
</listitem>
</varlistentry>
<varlistentry xml:id="constant.json-error-utf8">
<term>
<constant>JSON_ERROR_UTF8</constant>
(<type>integer</type>)
</term>
<listitem>
<simpara>
Malformed UTF-8 characters, possibly incorrectly encoded. This
constant is available as of PHP 5.3.3.
</simpara>
</listitem>
</varlistentry>
<varlistentry xml:id="constant.json-error-recursion">
<term>
<constant>JSON_ERROR_RECURSION</constant>
(<type>integer</type>)
</term>
<listitem>
<para>
The object or array passed to <function>json_encode</function> include
recursive references and cannot be encoded.
If the <constant>JSON_PARTIAL_OUTPUT_ON_ERROR</constant> option was
given, &null; will be encoded in the place of the recursive reference.
</para>
<para>
This constant is available as of PHP 5.5.0.
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="constant.json-error-inf-or-nan">
<term>
<constant>JSON_ERROR_INF_OR_NAN</constant>
(<type>integer</type>)
</term>
<listitem>
<para>
The value passed to <function>json_encode</function> includes either
<link linkend="language.types.float.nan"><constant>NAN</constant></link>
or <link linkend="function.is-infinite"><constant>INF</constant></link>.
If the <constant>JSON_PARTIAL_OUTPUT_ON_ERROR</constant> option was
given, <literal>0</literal> will be encoded in the place of these
special numbers.
</para>
<para>
This constant is available as of PHP 5.5.0.
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="constant.json-error-unsupported-type">
<term>
<constant>JSON_ERROR_UNSUPPORTED_TYPE</constant>
(<type>integer</type>)
</term>
<listitem>
<para>
A value of an unsupported type was given to
<function>json_encode</function>, such as a <type>resource</type>.
If the <constant>JSON_PARTIAL_OUTPUT_ON_ERROR</constant> option was
given, &null; will be encoded in the place of the unsupported value.
</para>
<para>
This constant is available as of PHP 5.5.0.
</para>
</listitem>
</varlistentry>
</variablelist>
<para>
The following constants can be combined to form options for
<function>json_encode</function>.
</para>
<variablelist>
<varlistentry xml:id="constant.json-hex-tag">
<term>
<constant>JSON_HEX_TAG</constant>
(<type>integer</type>)
</term>
<listitem>
<simpara>
All &lt; and &gt; are converted to \u003C and \u003E.
Available since PHP 5.3.0.
</simpara>
</listitem>
</varlistentry>
<varlistentry xml:id="constant.json-hex-amp">
<term>
<constant>JSON_HEX_AMP</constant>
(<type>integer</type>)
</term>
<listitem>
<simpara>
All &amp;s are converted to \u0026.
Available since PHP 5.3.0.
</simpara>
</listitem>
</varlistentry>
<varlistentry xml:id="constant.json-hex-apos">
<term>
<constant>JSON_HEX_APOS</constant>
(<type>integer</type>)
</term>
<listitem>
<simpara>
All ' are converted to \u0027.
Available since PHP 5.3.0.
</simpara>
</listitem>
</varlistentry>
<varlistentry xml:id="constant.json-hex-quot">
<term>
<constant>JSON_HEX_QUOT</constant>
(<type>integer</type>)
</term>
<listitem>
<simpara>
All " are converted to \u0022.
Available since PHP 5.3.0.
</simpara>
</listitem>
</varlistentry>
<varlistentry xml:id="constant.json-force-object">
<term>
<constant>JSON_FORCE_OBJECT</constant>
(<type>integer</type>)
</term>
<listitem>
<simpara>
Outputs an object rather than an array when a non-associative array is
used. Especially useful when the recipient of the output is expecting
an object and the array is empty.
Available since PHP 5.3.0.
</simpara>
</listitem>
</varlistentry>
<varlistentry xml:id="constant.json-numeric-check">
<term>
<constant>JSON_NUMERIC_CHECK</constant>
(<type>integer</type>)
</term>
<listitem>
<simpara>
Encodes numeric strings as numbers.
Available since PHP 5.3.3.
</simpara>
</listitem>
</varlistentry>
<varlistentry xml:id="constant.json-bigint-as-string">
<term>
<constant>JSON_BIGINT_AS_STRING</constant>
(<type>integer</type>)
</term>
<listitem>
<simpara>
Encodes large integers as their original string value.
Available since PHP 5.4.0.
</simpara>
</listitem>
</varlistentry>
<varlistentry xml:id="constant.json-pretty-print">
<term>
<constant>JSON_PRETTY_PRINT</constant>
(<type>integer</type>)
</term>
<listitem>
<simpara>
Use whitespace in returned data to format it.
Available since PHP 5.4.0.
</simpara>
</listitem>
</varlistentry>
<varlistentry xml:id="constant.json-unescaped-slashes">
<term>
<constant>JSON_UNESCAPED_SLASHES</constant>
(<type>integer</type>)
</term>
<listitem>
<simpara>
Don't escape <literal>/</literal>.
Available since PHP 5.4.0.
</simpara>
</listitem>
</varlistentry>
<varlistentry xml:id="constant.json-unescaped-unicode">
<term>
<constant>JSON_UNESCAPED_UNICODE</constant>
(<type>integer</type>)
</term>
<listitem>
<simpara>
Encode multibyte Unicode characters literally (default is to escape as \uXXXX).
Available since PHP 5.4.0.
</simpara>
</listitem>
</varlistentry>
<varlistentry xml:id="constant.json-partial-output-on-error">
<term>
<constant>JSON_PARTIAL_OUTPUT_ON_ERROR</constant>
(<type>integer</type>)
</term>
<listitem>
<simpara>
Substitute some unencodable values instead of failing.
Available since PHP 5.5.0.
</simpara>
</listitem>
</varlistentry>
<varlistentry xml:id="constant.json-preserve-zero-fraction">
<term>
<constant>JSON_PRESERVE_ZERO_FRACTION</constant>
(<type>integer</type>)
</term>
<listitem>
<simpara>
Ensures that <type>float</type> values are always encoded as a float value.
Available since PHP 5.6.6.
</simpara>
</listitem>
</varlistentry>
</variablelist>
</appendix>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->