元問答欄目視頻美女
  1. 編程問答
  2. 答案列表

php 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_bigint_as_string (integer)。
將大數字編碼成原始字符原來的值。自 php 5.4.0 起生效。
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 起生效。
一個經典的例子。
<?php
$array = ['中國','http://www.lcget.com/','337'];
$bad = json_encode($array);
$good = json_encode($array, json_unescaped_unicode | json_unescaped_slashes | json_numeric_check);
// $bad would be ["\u20ac","http:\/\/www.lcget.com\/","337"]。
// $good would be ["中國","http://www.lcget.com",337]。
>
猜你喜歡
相關推薦