refiking Posted August 27, 2009 Share Posted August 27, 2009 If I have a site where the url is domain.com/123&4/ and everything within the two "/" is the value for the variable (we'll call it $var), how can I make $var = '123&4'? Currently, when the value comes from the URL, it stops at the & symbol. Link to comment https://forums.phpfreaks.com/topic/172169-need-to-read-symbol-from-url/ Share on other sites More sharing options...
lemmin Posted August 27, 2009 Share Posted August 27, 2009 Try domain.com/123%264/ Link to comment https://forums.phpfreaks.com/topic/172169-need-to-read-symbol-from-url/#findComment-907774 Share on other sites More sharing options...
mikesta707 Posted August 27, 2009 Share Posted August 27, 2009 before you send the variables, you should use $title = urlencode($title); Then append it to the URL http://whatever.com/?title=$title When you read it, you will need to do $title = urldecode($_GET['title']); taken from : http://www.webxpertz.net/forums/archive/index.php/t-35671.html Link to comment https://forums.phpfreaks.com/topic/172169-need-to-read-symbol-from-url/#findComment-907775 Share on other sites More sharing options...
refiking Posted August 27, 2009 Author Share Posted August 27, 2009 Neither of these will work because these are dynamic links rewritten using mod rewrite. If someone types in domain.com/123&4 the variable still needs to return the entire string. Not just from a link I create using php. Link to comment https://forums.phpfreaks.com/topic/172169-need-to-read-symbol-from-url/#findComment-907791 Share on other sites More sharing options...
lemmin Posted August 27, 2009 Share Posted August 27, 2009 Can you not change the mod rewrite? Link to comment https://forums.phpfreaks.com/topic/172169-need-to-read-symbol-from-url/#findComment-907801 Share on other sites More sharing options...
refiking Posted August 27, 2009 Author Share Posted August 27, 2009 Change it to what? I didn't know you could do encoding or decoding to a mod rewrite... Link to comment https://forums.phpfreaks.com/topic/172169-need-to-read-symbol-from-url/#findComment-907807 Share on other sites More sharing options...
lemmin Posted August 27, 2009 Share Posted August 27, 2009 I don't know what the circumstance is exactly, but I would change it to use "%26" in place of '&'. That would allow you to catch the '&' symbol in PHP. Link to comment https://forums.phpfreaks.com/topic/172169-need-to-read-symbol-from-url/#findComment-907809 Share on other sites More sharing options...
refiking Posted August 27, 2009 Author Share Posted August 27, 2009 That didn't work, either. Link to comment https://forums.phpfreaks.com/topic/172169-need-to-read-symbol-from-url/#findComment-907845 Share on other sites More sharing options...
lemmin Posted August 27, 2009 Share Posted August 27, 2009 What happened? If that changes the URL to be /123%264/ then PHP will receive the whole string. Link to comment https://forums.phpfreaks.com/topic/172169-need-to-read-symbol-from-url/#findComment-907857 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.