<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Predefined Constants</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="json.resources.html">Resource Types</a></div> <div class="next" style="text-align: right; float: right;"><a href="class.jsonserializable.html">JsonSerializable</a></div> <div class="up"><a href="book.json.html">JSON</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="json.constants" class="appendix"> <h1>Predefined Constants</h1> <p class="simpara"> The constants below are defined by this extension, and will only be available when the extension has either been compiled into PHP or dynamically loaded at runtime. </p> <p class="para"> The following constants indicate the type of error returned by <span class="function"><a href="function.json-last-error.html" class="function">json_last_error()</a></span>. </p> <dl> <dt id="constant.json-error-none"> <span class="term"> <strong><code>JSON_ERROR_NONE</code></strong> (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>) </span> <dd> <span class="simpara"> No error has occurred. Available since PHP 5.3.0. </span> </dd> </dt> <dt id="constant.json-error-depth"> <span class="term"> <strong><code>JSON_ERROR_DEPTH</code></strong> (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>) </span> <dd> <span class="simpara"> The maximum stack depth has been exceeded. Available since PHP 5.3.0. </span> </dd> </dt> <dt id="constant.json-error-state-mismatch"> <span class="term"> <strong><code>JSON_ERROR_STATE_MISMATCH</code></strong> (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>) </span> <dd> <span class="simpara"> Occurs with underflow or with the modes mismatch. Available since PHP 5.3.0. </span> </dd> </dt> <dt id="constant.json-error-ctrl-char"> <span class="term"> <strong><code>JSON_ERROR_CTRL_CHAR</code></strong> (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>) </span> <dd> <span class="simpara"> Control character error, possibly incorrectly encoded. Available since PHP 5.3.0. </span> </dd> </dt> <dt id="constant.json-error-syntax"> <span class="term"> <strong><code>JSON_ERROR_SYNTAX</code></strong> (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>) </span> <dd> <span class="simpara"> Syntax error. Available since PHP 5.3.0. </span> </dd> </dt> <dt id="constant.json-error-utf8"> <span class="term"> <strong><code>JSON_ERROR_UTF8</code></strong> (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>) </span> <dd> <span class="simpara"> Malformed UTF-8 characters, possibly incorrectly encoded. This constant is available as of PHP 5.3.3. </span> </dd> </dt> <dt id="constant.json-error-recursion"> <span class="term"> <strong><code>JSON_ERROR_RECURSION</code></strong> (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>) </span> <dd> <p class="para"> The object or array passed to <span class="function"><a href="function.json-encode.html" class="function">json_encode()</a></span> include recursive references and cannot be encoded. If the <strong><code>JSON_PARTIAL_OUTPUT_ON_ERROR</code></strong> option was given, <strong><code>NULL</code></strong> will be encoded in the place of the recursive reference. </p> <p class="para"> This constant is available as of PHP 5.5.0. </p> </dd> </dt> <dt id="constant.json-error-inf-or-nan"> <span class="term"> <strong><code>JSON_ERROR_INF_OR_NAN</code></strong> (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>) </span> <dd> <p class="para"> The value passed to <span class="function"><a href="function.json-encode.html" class="function">json_encode()</a></span> includes either <a href="language.types.float.html#language.types.float.nan" class="link"><strong><code>NAN</code></strong></a> or <a href="function.is-infinite.html" class="link"><strong><code>INF</code></strong></a>. If the <strong><code>JSON_PARTIAL_OUTPUT_ON_ERROR</code></strong> option was given, <em>0</em> will be encoded in the place of these special numbers. </p> <p class="para"> This constant is available as of PHP 5.5.0. </p> </dd> </dt> <dt id="constant.json-error-unsupported-type"> <span class="term"> <strong><code>JSON_ERROR_UNSUPPORTED_TYPE</code></strong> (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>) </span> <dd> <p class="para"> A value of an unsupported type was given to <span class="function"><a href="function.json-encode.html" class="function">json_encode()</a></span>, such as a <span class="type"><a href="language.types.resource.html" class="type resource">resource</a></span>. If the <strong><code>JSON_PARTIAL_OUTPUT_ON_ERROR</code></strong> option was given, <strong><code>NULL</code></strong> will be encoded in the place of the unsupported value. </p> <p class="para"> This constant is available as of PHP 5.5.0. </p> </dd> </dt> </dl> <p class="para"> The following constants can be combined to form options for <span class="function"><a href="function.json-encode.html" class="function">json_encode()</a></span>. </p> <dl> <dt id="constant.json-hex-tag"> <span class="term"> <strong><code>JSON_HEX_TAG</code></strong> (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>) </span> <dd> <span class="simpara"> All < and > are converted to \u003C and \u003E. Available since PHP 5.3.0. </span> </dd> </dt> <dt id="constant.json-hex-amp"> <span class="term"> <strong><code>JSON_HEX_AMP</code></strong> (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>) </span> <dd> <span class="simpara"> All &s are converted to \u0026. Available since PHP 5.3.0. </span> </dd> </dt> <dt id="constant.json-hex-apos"> <span class="term"> <strong><code>JSON_HEX_APOS</code></strong> (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>) </span> <dd> <span class="simpara"> All ' are converted to \u0027. Available since PHP 5.3.0. </span> </dd> </dt> <dt id="constant.json-hex-quot"> <span class="term"> <strong><code>JSON_HEX_QUOT</code></strong> (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>) </span> <dd> <span class="simpara"> All " are converted to \u0022. Available since PHP 5.3.0. </span> </dd> </dt> <dt id="constant.json-force-object"> <span class="term"> <strong><code>JSON_FORCE_OBJECT</code></strong> (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>) </span> <dd> <span class="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. </span> </dd> </dt> <dt id="constant.json-numeric-check"> <span class="term"> <strong><code>JSON_NUMERIC_CHECK</code></strong> (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>) </span> <dd> <span class="simpara"> Encodes numeric strings as numbers. Available since PHP 5.3.3. </span> </dd> </dt> <dt id="constant.json-bigint-as-string"> <span class="term"> <strong><code>JSON_BIGINT_AS_STRING</code></strong> (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>) </span> <dd> <span class="simpara"> Encodes large integers as their original string value. Available since PHP 5.4.0. </span> </dd> </dt> <dt id="constant.json-pretty-print"> <span class="term"> <strong><code>JSON_PRETTY_PRINT</code></strong> (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>) </span> <dd> <span class="simpara"> Use whitespace in returned data to format it. Available since PHP 5.4.0. </span> </dd> </dt> <dt id="constant.json-unescaped-slashes"> <span class="term"> <strong><code>JSON_UNESCAPED_SLASHES</code></strong> (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>) </span> <dd> <span class="simpara"> Don't escape <em>/</em>. Available since PHP 5.4.0. </span> </dd> </dt> <dt id="constant.json-unescaped-unicode"> <span class="term"> <strong><code>JSON_UNESCAPED_UNICODE</code></strong> (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>) </span> <dd> <span class="simpara"> Encode multibyte Unicode characters literally (default is to escape as \uXXXX). Available since PHP 5.4.0. </span> </dd> </dt> </dl> </div> <hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="json.resources.html">Resource Types</a></div> <div class="next" style="text-align: right; float: right;"><a href="class.jsonserializable.html">JsonSerializable</a></div> <div class="up"><a href="book.json.html">JSON</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>