Personally, I prefer to read $_SERVER['REQUEST_URI'] and regex out the 
bits I need. I don't think this is hacky at all - it's actually more 
reliable across different server configs and gives you more control over 
how your URLs appear. This is a good way to go especially once you 
decide to rewrite your URLs as www.domain.com/search/dog+cat+rabbit/ - 
you can ignore the querystring variables which makes your life easier 
when writing your .htaccess rules.

Once you have regexed 'cat+dog+rabbit' into a variable, do a str_replace 
on the plusses to make them into spaces. Make sure you have handling 
such as for other special characters on the way in and out of the URL 
(ie when you create the search links and when you read them from the URL).

Hope that helps a bit.

Harvey.

matt_thomson wrote:
> Hi, I have a script that runs like: search.php?terms=dog+cat+rabbit
>
> echo $_GET['terms'] will output "dog cat rabbit" not "dog+cat+rabbit"
>
> This is not desirable as I want to be able to tell the difference
> between the end of a search term, and a space within a search term. I
> also want to use the plus, as it is intuitive for users if they want
> to edit the url manually.
>
> I have googled around and found a description of the why plus is
> replaced with a space here:
>
> http://bugs.php.net/bug.php?id=39078
>
> But there doesn't seem like there is any simple solutions. I am
> currently thinking it might be easiest to use $_SERVER["REQUEST_URI"]
> then regular expression it, but that seems like a bit of an ugly last
> resort way, does anyone have any better solutions.
>
> Thanks,
>
> Matt.
>
>   

-- 
Harvey Kane

New Zealand:
-Office: +64 9 950 4133
-Mobile: +6421 811 951

Email: [email protected]
 If you need to contact me urgently, please read my email policy 
www.ragepank.com/email/

-- 
NZ PHP Users Group: http://groups.google.com/group/nzphpug
To post, send email to [email protected]
To unsubscribe, send email to
[email protected]

Reply via email to