rhgiant — 2012-01-06T10:03:18-05:00 — #1
What would happen if I ever end up with a utl like this?
I am asking because I am making a redirect appending this bit to the incoming url: ?someothervar=test
My question is obviously: what happens if the incoming url already has a querystring (such as ?var1=blah&var2=ok) and I append to it ?someothervar=test ? Should I test for every incoming request to check if a querystring already exists?
raju_gautam — 2012-01-06T11:08:19-05:00 — #2
See print_r($_GET); to see what it gives you:
It will return you:
Array ( [var1] => blah [var2] => ok?someothervar=test )
Instead you should do something like this:
$url = 'http://somesite.com/?var1=blah&var2=ok'; // your existing url
// now you can append it like this by checking if ? exists:
$url .= (strpos($url, '?') === false) ? '?' : '&';
$url .= 'someothervar=test';
rhgiant — 2012-01-06T11:29:56-05:00 — #3
Worked like a charm... :tup:
I'm just having a bit of a problem with fragment identifiers. How should I format an url with a fragment identifier and a querystring?
http://somesite.com/#message?var1=blah&var2=ok?someothervar=test doesn't seem to work nicely.
raju_gautam — 2012-01-06T11:44:04-05:00 — #4
See the function parse_url and some examples there.
rhgiant — 2012-01-08T09:06:59-05:00 — #5
Hello, read it and the examples, I'm still not sure how the url should be formed. Parsing it is only a secondary concern. I just want the browser to recognize the fragment identifier AND use the querystring with PHP.
scallioxtx — 2012-01-08T09:50:00-05:00 — #6
The fragment identifier always comes last
rhgiant — 2012-01-09T12:45:06-05:00 — #7
It seems that the fragment identifier appears in $_GET['foo'] though.
$_GET['foo'] == bar#somefragment
Is there a solution to this?
cranial_bore — 2012-01-09T19:38:25-05:00 — #8
I didn't get that when I tried it (fragment coming through in GET value).
What does your link href look like in the HTML source (i.e. how is PHP rendering the URL)?
wh33t — 2012-01-09T19:44:51-05:00 — #9
Do you mean the Octet (or is it Octothorpe?) is appearing in your URLs and you'd like to remove them?