PHP、Rest服务、克罗地亚字母作为POST请求JSON正文中的参数值
我的PHP MVC有问题。我正试图在HTTP POST请求体中发送一些JSON参数值,其中包括来自Android客户端的克罗地亚符号,如ŠĆŽĐŽ。但是在PHP控制器方面,当我回显HTTP请求的JSON主体时,我得到了什么?问号,而不是我用的那些字母,文件内容php://input'; 我在网上找到的所有东西都试过了,但都没用。当我从MySQL数据库中获取一些包含这些字母的值,并在PHP中进行回显时,一切都正常 下面是代码的一部分。我对以前尝试过的一些代码进行了注释PHP、Rest服务、克罗地亚字母作为POST请求JSON正文中的参数值,php,json,rest,post,encoding,Php,Json,Rest,Post,Encoding,我的PHP MVC有问题。我正试图在HTTP POST请求体中发送一些JSON参数值,其中包括来自Android客户端的克罗地亚符号,如ŠĆŽĐŽ。但是在PHP控制器方面,当我回显HTTP请求的JSON主体时,我得到了什么?问号,而不是我用的那些字母,文件内容php://input'; 我在网上找到的所有东西都试过了,但都没用。当我从MySQL数据库中获取一些包含这些字母的值,并在PHP中进行回显时,一切都正常 下面是代码的一部分。我对以前尝试过的一些代码进行了注释 //header('Cont
//header('Content-Type: text/html; ISO-8859-1');
mb_language('uni');
mb_internal_encoding('UTF-8');
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
// get tag
//$opts = array('http' => array('header' => 'Accept-Charset: UTF-8'));
//$context = stream_context_create($opts);
inputJSON = file_get_contents('php://input');
echo utf8_encode($inputJSON);
echo $inputJSON;
//$fileEndEnd = mb_convert_encoding($inputJSON, 'UTF-8', 'UTF-16'); //$fileEndEnd = htmlentities($inputJSON, 'UTF-8', 'UTF-8');
//$string = http_get_request_body ();
//$string = iconv('UTF-8', 'ASCII//TRANSLIT', $inputJSON);
$fileEndEnd = mb_convert_encoding($inputJSON, 'UTF-8',mb_detect_encoding($inputJSON, 'UTF-8, ISO-8859-1', true));
//echo $fileEndEnd;
echo $fileEndEnd;
//echo $string;
//echo 'Badalićeva';
$input= json_decode($inputJSON);
//some code
function file_get_contents_utf8($fn) {
$content = file_get_contents($fn);
return mb_convert_encoding($content, 'UTF-8');
}