1

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...

  • 1
    In what way does it not work? Please post some code, what you expect it to output, and what it actually outputs. – tdammers Feb 11 '12 at 19:23

1 Answers1

2

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.

Community
  • 1
  • 1
daxnitro
  • 920
  • 6
  • 7
  • I understood my problem. I am using codeigniter and it ignores comma char in uri. Do you know how I can solve this problem? – Cemil Tokatlı Feb 11 '12 at 23:38