php base64 decode乱码的解决办法:首先打开相应的PHP文件;然后在在使用“base64_decode”解码之前添加语句为“ $encodedData = str_replace('+',$encodedData);”即可。

推荐:《PHP视频教程》
前几天出现的问题,GET和POST请求中的字符串经过base64_decode之后乱码了,查了一下是PHP的问题,在使用base64_decode解码之前先加一句:
$encodedData = str_replace(' ','+',$encodedData);
$decocedData = base64_decode($encodedData);就好了。
如果字符串过长,还需要先替换再分段解码:
$encoded = str_replace(' ','+',$encoded);
$decoded = "";
for ($i=0; $i < ceil(strlen($encoded)/256); $i++)
$decoded = $decoded . base64_decode(substr($encoded,$i*256,256));以上就是php base64 decode乱码问题的解决办法的详细内容,更多请关注php中文网其它相关文章!
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号