php:
prepare($sql);
$sth->bindParam(':username', $user_name);
// $sth->bindParam(':pwd', $up);
$sth->execute();
$rs = $sth->fetchAll(PDO::FETCH_ASSOC);
return $rs;
}
?>
接收到的user_name是乱码,这里是需要设置post时的headers吗?应该如何设置。
出于各种原因,需要最大限度地兼容以前的系统,所以要用gb2312.
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
我在php中使用如下代码解决了问题:
$params = json_decode(file_get_contents('php://input'), true);
require("cfg.php");
global $dbh;
$user_name = $params["uname"];//utf-8
$user_name = iconv("UTF-8", "GB2312", $user_name);