Jump to content

[SOLVED] url variable name itself has space in it... how can I retrieve it in php??


Recommended Posts

Hi, I got this problem, where I need to capture get url variable pairs, but these are coming from an automatically created javascript and has this format:

page?custom zip=33021&custom city=boston... and so on...

 

If you notice the actual variable-names have spaces in it (custom zip, custom city; as opposed to normally named customzip, customcity) and when i try to capture them in php like this:

<?php echo $_GET['custom zip']; ?>

 

it doesnt do it... But if I manually change my url and join the variables like this: "customzip=33021" and change php accordingly, then it echoes it with no problem!

 

So I think is cause php doesnt like the actual variable to have spaces in it.. so how do I get to read it??

 

thanks, appreciate feedback...

Thanks Guys... adn Mchl, you are awesome! Your suggestion worked like a charm!!  I couldnt believe it was such a simple fix... simply making the space a hiphen did it beautifully. So does PHP automatically pick up spaces as underscores? does that happen only in this case when dealing with variables??

 

Thanks a lot!!

I think it will work only with GET and POST variables. It will also change other character that are invalid in variable names to underscore.

 

http://www.php.net/manual/en/language.variables.external.php

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.