json_encode函数参数详解
json_encode($arr,448)等于设置了多个参数。
448=64+128+256 64即不转换\ 128 不转换\n \r \t之类的空⽩ 256中⽂输出
JSON_UNESCAPED_SLASHES => 64
phpjson格式化输出
JSON_PRETTY_PRINT => 128
JSON_UNESCAPED_UNICODE => 256
json_encode() 具体参数
JSON_HEX_TAG(integer)
所有的 < 和 > 转换成 \u003C 和 \u003E。 ⾃ PHP 5.3.0 起⽣效。
JSON_HEX_AMP (integer)
所有的 & 转换成 \u0026。 ⾃ PHP 5.3.0 起⽣效。
JSON_HEX_APOS (integer)
所有的 ' 转换成 \u0027。 ⾃ PHP 5.3.0 起⽣效。
JSON_HEX_QUOT (integer)
所有的 " 转换成 \u0022。 ⾃ PHP 5.3.0 起⽣效。
JSON_FORCE_OBJECT (integer)
使⼀个⾮关联数组输出⼀个类(Object)⽽⾮数组。 在数组为空⽽接受者需要⼀个类(Object)的时候尤其有⽤。 ⾃ PHP 5.3.0 起⽣效。
JSON_NUMERIC_CHECK (integer)
将所有数字字符串编码成数字(numbers)。 ⾃ PHP 5.3.3 起⽣效。
JSON_PRETTY_PRINT (integer)
⽤空⽩字符格式化返回的数据。 ⾃ PHP 5.4.0 起⽣效。
JSON_UNESCAPED_SLASHES (integer)
不要编码 /。 ⾃ PHP 5.4.0 起⽣效。
JSON_UNESCAPED_UNICODE (integer)
以字⾯编码多字节 Unicode 字符(默认是编码成 \uXXXX)。 ⾃ PHP 5.4.0 起⽣效。
JSON_PARTIAL_OUTPUT_ON_ERROR (integer)
Substitute some unencodable values instead of failing. Available since PHP 5.5.0.
JSON_PRESERVE_ZERO_FRACTION (integer)
Ensures that float values are always encoded as a float value. Available since PHP 5.6.6.
JSON_UNESCAPED_LINE_TERMINATORS (integer)
The line terminators are kept unescaped when
JSON_UNESCAPED_UNICODE is supplied. It uses the same behaviour as it was before PHP 7.1 without this constant.
Available since PHP 7.1.0.
JSON_HEX_TAG => 1
JSON_HEX_AMP => 2
JSON_HEX_APOS => 4
JSON_HEX_QUOT => 8
JSON_FORCE_OBJECT => 16
JSON_NUMERIC_CHECK => 32
JSON_UNESCAPED_SLASHES => 64
JSON_PRETTY_PRINT => 128
JSON_UNESCAPED_UNICODE => 256
JSON_ERROR_DEPTH => 1
JSON_ERROR_STATE_MISMATCH => 2
JSON_ERROR_CTRL_CHAR => 3
JSON_ERROR_SYNTAX => 4
JSON_ERROR_UTF8 => 5
JSON_OBJECT_AS_ARRAY => 1 JSON_BIGINT_AS_STRING => 2

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。