Cemil Tokatlı
Cemil Tokatlı

Reputation: 21

PHP-JavaScript URL decode-encode

I need to encode an url in javascript and decode it in php.. how can I do this? I tried using encodeURI and encodeURIComponent functions with urldecode in php but it doesnt work...

Upvotes: 1

Views: 3298

Answers (1)

daxnitro
daxnitro

Reputation: 920

Encoding URLs in Javascript should work fine with encodeURI(). See here:

Encode URL in JavaScript?

In PHP, if the URL you're reading is being passed through a GET parameter, there's no need to decode it. It's already been done. Otherwise, urldecode() is your answer.

You're gonna need to post more info if you need more help.

Upvotes: 2

Related Questions