PHP中base64_encode编码乱码的解决方法

使用base64_encode 转码某些汉字后 ,用base64_decode转换回来却发现乱码。我是在用base64_encode编码后使用GET方式传参后,用base64_decode转换回来就乱码,最后研究发现有些汉字使用base64_encode编码后里边含有“+”号,用GET形式传过来的时候,+号会被替换成空格,所以出现了乱码。我们在用base64_decode转换回来的时候,将空格替换成+号就可以解决乱码了。
示例:
$tips=base64_decode(str_replace(" ","+",$_GET['tips']));//先使用str_replace 将传过来的值(tips)中的空格替换成+号,再转换编码
版权声明:
作者:东明兄
链接:https://blog.crazyming.com/note/196/
来源:CrazyMing
文章版权归作者所有,未经允许请勿转载。


共有 0 条评论