MadTechie Posted March 1, 2007 Share Posted March 1, 2007 ok a simple question i hope i need to pass a get string but the variable requires a dot (.) but php converts this to a underscore (_) this normally wouldn't be a problem but some variables use the underscore heres some basic code url = index.php?my.foo=hello&my_foo2=world <?php print "my.foo:".$_GET['my.foo']."<br />"; print "my_foo:".$_GET['my_foo']."<br />"; print "my_foo2:".$_GET['my_foo2']."<br />"; print_r($_GET); ?> any ideas how to resolve this, as a note the variable names are pulled in from a data file created by the user Quote Link to comment https://forums.phpfreaks.com/topic/40642-getmyfoo/ Share on other sites More sharing options...
btherl Posted March 1, 2007 Share Posted March 1, 2007 Are you able to encode the variable name as well as its value? For example $varname = 'my.foo'; $varval = 'hello'; $encoded = urlencode("$varname=$varval"); $url = "index.php?var=$encoded"; Quote Link to comment https://forums.phpfreaks.com/topic/40642-getmyfoo/#findComment-196610 Share on other sites More sharing options...
MadTechie Posted March 1, 2007 Author Share Posted March 1, 2007 true, i'll see if i can add it into my code Thanx btherl Quote Link to comment https://forums.phpfreaks.com/topic/40642-getmyfoo/#findComment-196614 Share on other sites More sharing options...
MadTechie Posted March 25, 2007 Author Share Posted March 25, 2007 urlencode doesn't solve the dot (.) problem, anyone have another idea ? Quote Link to comment https://forums.phpfreaks.com/topic/40642-getmyfoo/#findComment-214581 Share on other sites More sharing options...
kenrbnsn Posted March 25, 2007 Share Posted March 25, 2007 Can you change the variables passed by the URL to use arrays? If you can you can then say: url = index.php?my.foo[]=hello&my_foo[]=world and your script would then see both values in the array $_GET['my_foo'] Ken Quote Link to comment https://forums.phpfreaks.com/topic/40642-getmyfoo/#findComment-214595 Share on other sites More sharing options...
MadTechie Posted March 25, 2007 Author Share Posted March 25, 2007 Problem is only the my_foo[] would be returned.. when i'll be expecting my.foo[] Quote Link to comment https://forums.phpfreaks.com/topic/40642-getmyfoo/#findComment-214602 Share on other sites More sharing options...
kenrbnsn Posted March 25, 2007 Share Posted March 25, 2007 Here is one way around the problem, but to use it you will have to change some of your logic. Make the URL look like this: url = index.php?p[my.foo]=1&p[my_foo]=2 then you could use $_GET['p']['my.foo'] and $_GET['p']['my_foo'] Ken Quote Link to comment https://forums.phpfreaks.com/topic/40642-getmyfoo/#findComment-214615 Share on other sites More sharing options...
MadTechie Posted March 25, 2007 Author Share Posted March 25, 2007 lol, love it thats one way i'll have a play see how deep my hole currently is (not sure how much needs updating) thanx kenrbnsn Quote Link to comment https://forums.phpfreaks.com/topic/40642-getmyfoo/#findComment-214619 Share on other sites More sharing options...
sps Posted March 25, 2007 Share Posted March 25, 2007 Edit : My apologies, didn't read the last line of your original post, made my response invalid. Quote Link to comment https://forums.phpfreaks.com/topic/40642-getmyfoo/#findComment-214713 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.