base64decode返回空白

时间:2015-06-24 08:17:16

标签: php base64

我正在尝试解码这个基本64位编码的url字符串并且它一直保持返回空白为什么会这样?

return strtr(base64_encode($url), '+/=', '-_,');

return base64_decode(strtr($url, '-_,', '+/='));

编码网址是aHR0cDovL3Rlc3QuZ3J5cGhvbnRlYS5jb20vbWFnZW50by9zdG9yZS5odG1s

2 个答案:

答案 0 :(得分:2)

只是因为你的strtr在解码中没用。 试试吧:

return base64_decode($url);

你的网址是:

  

http://test.gryphontea.com/magento/store.html

那应该做的。

base64_decode(strtr($url, '-_,', '+/='));

使用strstr,您尝试转到子串" -_,",并且在您的编码网址中没有这样的部分。然后你尝试base64_decode它,因为strstr"失败"它返回""。 然后你就得到了:

base64_decode("");

答案 1 :(得分:1)

也许首先将您的$ url转换为$ var,进行转换,然后返回字符串,但我不相信您的strtr转换是正确的。