Jump to content

[SOLVED] URI problems


xenophobia

Recommended Posts

so let say I got a php filename: my.php which receive a request of myvar:

my.php?myvar=hello world

So $_REQUEST['myvar'] will get the data.

 

how if I wan my 'myvar' contained an ampersand? Which looks like:

my.php?myvar=hello&world

So it became two request:

$_REQUEsT['myvar'] and $_REQUEST['word']

 

Any solutions?

Link to comment
https://forums.phpfreaks.com/topic/52306-solved-uri-problems/
Share on other sites

If you are constructing the URL in php, do it like this:

 

$url = 'my.php?myvar=' . urlencode($myvar);

 

When browsers submit form data, they do this process automatically, so it's only necessary for when you construct your own urls.  When you receive the data in $_REQUEST['myvar'], you must use urldecode() to convert it back.

Link to comment
https://forums.phpfreaks.com/topic/52306-solved-uri-problems/#findComment-258030
Share on other sites

Actually Im using Ajax to send the url. So there will be no any function like urlencode in javascript. :'(

 

But anyway thanks for that function and i discovered that '&' is equals to %26. So i just replace the url string from & -> %26. And is work. Thanks anyway.

Link to comment
https://forums.phpfreaks.com/topic/52306-solved-uri-problems/#findComment-258035
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.