<?php header(‘Content-type:text/html;charset=utf-8‘); $s = array(‘message‘=>‘4月以降、遺体の捜索活動が続けられてきたが‘); $sJSON = json_encode($s); var_dump($sJSON); // 会转换成16进制 var_dump(json_decode($sJSON)); $sJSON = json_encode($s, defined(‘JSON_UNESCAPED_UNICODE‘) ? JSON_UNESCAPED_UNICODE : 0); if (!defined(‘JSON_UNESCAPED_UNICODE‘) && function_exists(‘mb_convert_encoding‘)) { $sJSON = preg_replace_callback( ‘~\\\\u([0-9a-f]{4})~i‘, create_function(‘$aMatches‘, ‘return mb_convert_encoding(pack("H*", $aMatches[1]), "UTF-8", "UTF-16");‘), $sJSON); } var_dump($sJSON); var_dump(json_decode($sJSON));
时间: 2024-10-06 02:35:17