zaw
zaw

Reputation: 684

base64decode returning blank

I am trying to decode this base 64 encoded url string and it keeps returning blank why is that?

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

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

encoded url is this aHR0cDovL3Rlc3QuZ3J5cGhvbnRlYS5jb20vbWFnZW50by9zdG9yZS5odG1s

Upvotes: 2

Views: 2107

Answers (2)

vr_driver
vr_driver

Reputation: 2085

Maybe convert your $url first to a $var, do your conversions, and then return the string, but I'm not convinced your strtr conversion is correct.

Upvotes: 1

kaldoran
kaldoran

Reputation: 855

Just cause your strtr in the decode is useless. Try just :

return base64_decode($url);

your url was :

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

That should do the job.

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

With strstr you try to go to substring "-_,", and in your encoded url there is no such part. Then you try to base64_decode it, as strstr "fail" it return "". then you've got :

base64_decode("");

Upvotes: 2

Related Questions