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
  • 1
    In what way does it not work? Please post some code, what you expect it to output, and what it actually outputs. Commented Feb 11, 2012 at 19:23

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

I understood my problem. I am using codeigniter and it ignores comma char in uri. Do you know how I can solve this problem?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.