0

There is a string XX&YY and I'm passing it to another page. ie, localhost/sample/XX&YY/1 for some processing. Now when I try getting the name value on the other side I'm able to get only XX and not full XX&YY. How to rectify it? Any ideas?

Note : here is my url localhost/sample.php?name=somevalue&pageno=somevalue has been url re-written to localhost/sample/name/pageno.

1
  • are you using URL rewritting? anyway you should encode the & as it's used to determine whenever you have a new parameter Commented Apr 12, 2013 at 7:44

2 Answers 2

2

You have to escape the URL . You can use rawurlencode() or urlencode() to encode your URL.

sidenote: Difference of the 2 functions

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

Comments

0

If I'm understanding correctly, this is the URL to your script:

http://localhost/sample/name/pageno

Which is then rewritten by your web server to this:

http://localhost/sample.php?name=somevalue&pageno=somevalue

Then, this is how you should format the URL:

$url = sprintf('http://localhost/sample/%s/%s', 
    urlencode('XX&YY'), 
    urlencode('1')
);

Comments

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.