Page 1 of 1

Point them to Mobile site - how?

Posted: Mon Feb 04, 2013 9:57 am
by simonmlewis
Hi
I am after a bit of advice.
We have a web site that uses a PHP preg_match script to determine if they are on iphone, blackberry or android (yes I know there are others). And if they are, it redirects them straight to the mobile version.

However, we want to give them the option to "go to Normal site" should they want to, since many phones now show the normal site just as well - and often it has more features anyway.

Code: Select all

if ((preg_match("/(iPhone|BlackBerry|Android)/", $_SERVER["HTTP_USER_AGENT"]) || ($cookiedevice == NULL))
{   ... }
I did this would work with the extra bit on the end - so they'd go to the mobile site, and click to use normal site. That would then store a $cookie saying "normalbrowser" for example, and as such that cookie is no longer NULL, and it keeps them on the normal site.

But this won't work, because it's an "||" or statement. So what's the best way to do this?

Re: Point them to Mobile site - how?

Posted: Mon Feb 04, 2013 2:23 pm
by requinix
You've correctly identified that a || will not work for this. What else could you use instead?