3 回答
TA贡献1865条经验 获得超7个赞
json_encode( $text, JSON_UNESCAPED_UNICODE );
例子:
/tmp $ cat test.php
<?php
echo json_encode(['key'=>'ыфва']), PHP_EOL;
echo json_encode(['key'=>'ыфва'], JSON_UNESCAPED_UNICODE), PHP_EOL;
/tmp $ php test.php
{"key":"\u044b\u0444\u0432\u0430"}
{"key":"ыфва"}
/tmp $ php --version
PHP 7.3.6 (cli) (built: May 31 2019 23:38:25) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.6, Copyright (c) 1998-2018 Zend Technologies
with Xdebug v2.7.2, Copyright (c) 2002-2019, by Derick Rethans
with Zend OPcache v7.3.6, Copyright (c) 1999-2018, by Zend Technologies
TA贡献2041条经验 获得超4个赞
您应该使用 $_POST 来获取表单数据,如下所示
header("Content-type: application/json; charset=utf-8");
file_put_contents('export.json', json_encode($_POST) );
TA贡献1824条经验 获得超6个赞
试试这个(来源):
header("Content-type: application/json; charset=utf-8")
$convert = file_put_contents('export.json', json_encode($_REQUEST));
$convert = iconv('CP1251', 'UTF-8', $convert);
- 3 回答
- 0 关注
- 179 浏览
添加回答
举报