svn: /phpdoc/en/trunk/reference/json/ constants.xml functions/json-decode.xml functions/json-encode.xml functions/json-last-error.xml

From: Date: Thu, 16 Jun 2011 12:55:11 +0000
Subject: svn: /phpdoc/en/trunk/reference/json/ constants.xml functions/json-decode.xml functions/json-encode.xml functions/json-last-error.xml
Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-8278@lists.php.net to get a copy of this message
vrana Thu, 16 Jun 2011 12:55:11 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=312207 Log: Constants Changed paths: U phpdoc/en/trunk/reference/json/constants.xml U phpdoc/en/trunk/reference/json/functions/json-decode.xml U phpdoc/en/trunk/reference/json/functions/json-encode.xml U phpdoc/en/trunk/reference/json/functions/json-last-error.xml Modified: phpdoc/en/trunk/reference/json/constants.xml =================================================================== --- phpdoc/en/trunk/reference/json/constants.xml 2011-06-16 12:47:39 UTC (rev 312206) +++ phpdoc/en/trunk/reference/json/constants.xml 2011-06-16 12:55:11 UTC (rev 312207) @@ -34,6 +34,17 @@ </varlistentry> <varlistentry> <term> + <constant>JSON_ERROR_STATE_MISMATCH</constant> + (<type>integer</type>) + </term> + <listitem> + <simpara> + Occurs with underflow or with the modes mismatch. + </simpara> + </listitem> + </varlistentry> + <varlistentry> + <term> <constant>JSON_ERROR_CTRL_CHAR</constant> (<type>integer</type>) </term> @@ -131,6 +142,18 @@ </simpara> </listitem> </varlistentry> + <varlistentry> + <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> </variablelist> </appendix> Modified: phpdoc/en/trunk/reference/json/functions/json-decode.xml =================================================================== --- phpdoc/en/trunk/reference/json/functions/json-decode.xml 2011-06-16 12:47:39 UTC (rev 312206) +++ phpdoc/en/trunk/reference/json/functions/json-decode.xml 2011-06-16 12:55:11 UTC (rev 312207) @@ -185,17 +185,18 @@ ); // Define the errors. -$json_errors = array( - JSON_ERROR_NONE => 'No error has occurred', - JSON_ERROR_DEPTH => 'The maximum stack depth has been exceeded', - JSON_ERROR_CTRL_CHAR => 'Control character error, possibly incorrectly encoded', - JSON_ERROR_SYNTAX => 'Syntax error', -); +$constants = get_defined_constants(true); +$json_errors = array(); +foreach ($constants["json"] as $name => $value) { + if (!strncmp($name, "JSON_ERROR_", 11)) { + $json_errors[$value] = $name; + } +} // Show the errors for different depths. foreach(range(4, 3, -1) as $depth) { var_dump(json_decode($json, True, $depth)); - echo 'Last error : ', $json_errors[json_last_error()], PHP_EOL, PHP_EOL; + echo 'Last error: ', $json_errors[json_last_error()], PHP_EOL, PHP_EOL; } ?> ]]> @@ -222,10 +223,10 @@ } } } -Last error : No error has occurred +Last error: JSON_ERROR_NONE NULL -Last error : The maximum stack depth has been exceeded +Last error: JSON_ERROR_DEPTH ]]> </screen> </example> Modified: phpdoc/en/trunk/reference/json/functions/json-encode.xml =================================================================== --- phpdoc/en/trunk/reference/json/functions/json-encode.xml 2011-06-16 12:47:39 UTC (rev 312206) +++ phpdoc/en/trunk/reference/json/functions/json-encode.xml 2011-06-16 12:55:11 UTC (rev 312207) @@ -43,6 +43,7 @@ <constant>JSON_HEX_TAG</constant>, <constant>JSON_HEX_AMP</constant>, <constant>JSON_HEX_APOS</constant>, + <constant>JSON_NUMERIC_CHECK</constant>, <constant>JSON_FORCE_OBJECT</constant>. </para> </listitem> Modified: phpdoc/en/trunk/reference/json/functions/json-last-error.xml =================================================================== --- phpdoc/en/trunk/reference/json/functions/json-last-error.xml 2011-06-16 12:47:39 UTC (rev 312206) +++ phpdoc/en/trunk/reference/json/functions/json-last-error.xml 2011-06-16 12:55:11 UTC (rev 312207) @@ -50,13 +50,13 @@ <entry></entry> </row> <row> - <entry><constant>JSON_ERROR_CTRL_CHAR</constant></entry> - <entry>Control character error, possibly incorrectly encoded</entry> + <entry><constant>JSON_ERROR_STATE_MISMATCH</constant></entry> + <entry>Invalid or malformed JSON</entry> <entry></entry> </row> <row> - <entry><constant>JSON_ERROR_STATE_MISMATCH</constant></entry> - <entry>Invalid or malformed JSON</entry> + <entry><constant>JSON_ERROR_CTRL_CHAR</constant></entry> + <entry>Control character error, possibly incorrectly encoded</entry> <entry></entry> </row> <row> @@ -97,18 +97,27 @@ switch(json_last_error()) { + case JSON_ERROR_NONE: + echo ' - No errors'; + break; case JSON_ERROR_DEPTH: echo ' - Maximum stack depth exceeded'; break; + case JSON_ERROR_STATE_MISMATCH: + echo ' - Underflow or the modes mismatch'; + break; case JSON_ERROR_CTRL_CHAR: echo ' - Unexpected control character found'; break; case JSON_ERROR_SYNTAX: echo ' - Syntax error, malformed JSON'; break; - case JSON_ERROR_NONE: - echo ' - No errors'; + case JSON_ERROR_UTF8: + echo ' - Malformed UTF-8 characters, possibly incorrectly encoded'; break; + default: + echo ' - Unknown error'; + break; } echo PHP_EOL;

« previous php.doc.cvs (#8278) next »