Sophie

Sophie

distrib > Mageia > 7 > armv7hl > by-pkgid > 2b917e0437961edec048f1d15e2d7449 > files > 9329

php-manual-en-7.2.11-1.mga7.noarch.rpm

<!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.jsonexception.html">JsonException</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">
    <strong><code>JSON_ERROR_NONE</code></strong>
     (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>)
   </dt>

   <dd>

    <span class="simpara">
     No error has occurred.
     Available since PHP 5.3.0.
    </span>
   </dd>

  
  
   <dt id="constant.json-error-depth">
    <strong><code>JSON_ERROR_DEPTH</code></strong>
     (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>)
   </dt>

   <dd>

    <span class="simpara">
     The maximum stack depth has been exceeded.
     Available since PHP 5.3.0.
    </span>
   </dd>

  
  
   <dt id="constant.json-error-state-mismatch">
    <strong><code>JSON_ERROR_STATE_MISMATCH</code></strong>
     (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>)
   </dt>

   <dd>

    <span class="simpara">
     Occurs with underflow or with the modes mismatch.
     Available since PHP 5.3.0.
    </span>
   </dd>

  
  
   <dt id="constant.json-error-ctrl-char">
    <strong><code>JSON_ERROR_CTRL_CHAR</code></strong>
     (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>)
   </dt>

   <dd>

    <span class="simpara">
     Control character error, possibly incorrectly encoded.
     Available since PHP 5.3.0.
    </span>
   </dd>

  
  
   <dt id="constant.json-error-syntax">
    <strong><code>JSON_ERROR_SYNTAX</code></strong>
     (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>)
   </dt>

   <dd>

    <span class="simpara">
     Syntax error.
     Available since PHP 5.3.0.
    </span>
   </dd>

  
  
   <dt id="constant.json-error-utf8">
    <strong><code>JSON_ERROR_UTF8</code></strong>
     (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>)
   </dt>

   <dd>

    <span class="simpara">
     Malformed UTF-8 characters, possibly incorrectly encoded.
     Available since PHP 5.3.3.
    </span>
   </dd>

  
  
   <dt id="constant.json-error-recursion">
    <strong><code>JSON_ERROR_RECURSION</code></strong>
     (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>)
   </dt>

   <dd>

    <span class="simpara">
     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.
     Available since PHP 5.5.0.
    </span>
   </dd>

  
  
   <dt id="constant.json-error-inf-or-nan">
    <strong><code>JSON_ERROR_INF_OR_NAN</code></strong>
     (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>)
   </dt>

   <dd>

    <span class="simpara">
     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.
     Available since PHP 5.5.0.
    </span>
   </dd>

  
  
   <dt id="constant.json-error-unsupported-type">
    <strong><code>JSON_ERROR_UNSUPPORTED_TYPE</code></strong>
     (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>)
   </dt>

   <dd>

    <span class="simpara">
     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.
     Available since PHP 5.5.0.
    </span>
   </dd>

  
  
   <dt id="constant.json-error-invalid-property-name">
    <strong><code>JSON_ERROR_INVALID_PROPERTY_NAME</code></strong>
    (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>)
   </dt>

   <dd>

    <span class="simpara">
     A key starting with \u0000 character was in the string passed to
     <span class="function"><a href="function.json-decode.html" class="function">json_decode()</a></span> when decoding a JSON object into a PHP
     object.
     Available since PHP 7.0.0.
    </span>
   </dd>

  
  
   <dt id="constant.json-error-utf16">
    <strong><code>JSON_ERROR_UTF16</code></strong>
    (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>)
   </dt>

   <dd>

    <span class="simpara">
     Single unpaired UTF-16 surrogate in unicode escape contained in the
     JSON string passed to <span class="function"><a href="function.json-encode.html" class="function">json_encode()</a></span>.
     Available since PHP 7.0.0.
    </span>
   </dd>

  
 </dl>


 <p class="para">
  The following constants can be combined to form options for
  <span class="function"><a href="function.json-decode.html" class="function">json_decode()</a></span>.
 </p>
 <dl>

  
   <dt id="constant.json-bigint-as-string">
    <strong><code>JSON_BIGINT_AS_STRING</code></strong>
    (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>)
   </dt>

   <dd>

    <span class="simpara">
     Decodes large integers as their original string value.
     Available since PHP 5.4.0.
    </span>
   </dd>

  
  
   <dt id="constant.json-object-as-array">
    <strong><code>JSON_OBJECT_AS_ARRAY</code></strong>
    (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>)
   </dt>

   <dd>

    <span class="simpara">
     Decodes JSON objects as PHP array. This option can be added automatically
     by calling <span class="function"><a href="function.json-decode.html" class="function">json_decode()</a></span> with the second parameter
     equal to <strong><code>TRUE</code></strong>.
     Available since PHP 5.4.0.
    </span>
   </dd>

  
 </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">
    <strong><code>JSON_HEX_TAG</code></strong>
     (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>)
   </dt>

   <dd>

    <span class="simpara">
     All &lt; and &gt; are converted to \u003C and \u003E.
     Available since PHP 5.3.0.
    </span>
   </dd>

  
  
   <dt id="constant.json-hex-amp">
    <strong><code>JSON_HEX_AMP</code></strong>
     (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>)
   </dt>

   <dd>

    <span class="simpara">
     All &amp;s are converted to \u0026.
     Available since PHP 5.3.0.
    </span>
   </dd>

  
  
   <dt id="constant.json-hex-apos">
    <strong><code>JSON_HEX_APOS</code></strong>
     (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>)
   </dt>

   <dd>

    <span class="simpara">
     All &#039; are converted to \u0027.
     Available since PHP 5.3.0.
    </span>
   </dd>

  
  
   <dt id="constant.json-hex-quot">
    <strong><code>JSON_HEX_QUOT</code></strong>
     (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>)
   </dt>

   <dd>

    <span class="simpara">
     All &quot; are converted to \u0022.
     Available since PHP 5.3.0.
    </span>
   </dd>

  
  
   <dt id="constant.json-force-object">
    <strong><code>JSON_FORCE_OBJECT</code></strong>
     (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>)
   </dt>

   <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 id="constant.json-numeric-check">
    <strong><code>JSON_NUMERIC_CHECK</code></strong>
     (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>)
   </dt>

   <dd>

    <span class="simpara">
     Encodes numeric strings as numbers.
     Available since PHP 5.3.3.
    </span>
   </dd>

  
  
   <dt id="constant.json-pretty-print">
    <strong><code>JSON_PRETTY_PRINT</code></strong>
     (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>)
   </dt>

   <dd>

    <span class="simpara">
     Use whitespace in returned data to format it.
     Available since PHP 5.4.0.
    </span>
   </dd>

  
  
   <dt id="constant.json-unescaped-slashes">
    <strong><code>JSON_UNESCAPED_SLASHES</code></strong>
     (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>)
   </dt>

   <dd>

    <span class="simpara">
     Don&#039;t escape <em>/</em>.
     Available since PHP 5.4.0.
    </span>
   </dd>

  
  
   <dt id="constant.json-unescaped-unicode">
    <strong><code>JSON_UNESCAPED_UNICODE</code></strong>
     (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>)
   </dt>

   <dd>

    <span class="simpara">
     Encode multibyte Unicode characters literally (default is to escape as
     \uXXXX).
     Available since PHP 5.4.0.
    </span>
   </dd>

  
  
   <dt id="constant.json-partial-output-on-error">
    <strong><code>JSON_PARTIAL_OUTPUT_ON_ERROR</code></strong>
     (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>)
   </dt>

   <dd>

    <span class="simpara">
     Substitute some unencodable values instead of failing.
     Available since PHP 5.5.0.
    </span>
   </dd>

  
  
   <dt id="constant.json-preserve-zero-fraction">
    <strong><code>JSON_PRESERVE_ZERO_FRACTION</code></strong>
     (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>)
   </dt>

   <dd>

    <span class="simpara">
     Ensures that <span class="type"><a href="language.types.float.html" class="type float">float</a></span> values are always encoded as a float
     value.
     Available since PHP 5.6.6.
    </span>
   </dd>

  
  
   <dt id="constant.json-unescaped-line-terminators">
    <strong><code>JSON_UNESCAPED_LINE_TERMINATORS</code></strong>
    (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>)
   </dt>

   <dd>

    <span class="simpara">
     The line terminators are kept unescaped when
     <strong><code>JSON_UNESCAPED_UNICODE</code></strong> is supplied. It uses the same
     behaviour as it was before PHP 7.1 without this constant.
     Available since PHP 7.1.0.
    </span>
   </dd>

  
 </dl>


 <p class="para">
  The following constants can be combined to form options for
  <span class="function"><a href="function.json-decode.html" class="function">json_decode()</a></span> and <span class="function"><a href="function.json-encode.html" class="function">json_encode()</a></span>.
 </p>
 <dl>

  
   <dt id="constant.json-throw-on-error">
    <strong><code>JSON_THROW_ON_ERROR</code></strong>
    (<span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>)
   </dt>

   <dd>

    <span class="simpara">
     Throws <a href="class.jsonexception.html" class="classname">JsonException</a> if an error occurs instead 
     of setting the global error state that is retrieved with
     <span class="function"><a href="function.json-last-error.html" class="function">json_last_error()</a></span>. 
     <strong><code>JSON_PARTIAL_OUTPUT_ON_ERROR</code></strong> takes precedence over
     <strong><code>JSON_THROW_ON_ERROR</code></strong>. Available since PHP 7.3.0.
    </span>
   </dd>

  
 </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.jsonexception.html">JsonException</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>