Include file unless Opera 7?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Include file unless Opera 7?

Post by JAB Creations »

This was my attempt but go figure, it does not work...

Code: Select all

$useragent = $_SERVER['HTTP_USER_AGENT'];
if (!eregi("Opera/7") || !eregi("Opera 7")) {include("includes-noscript.php");}
nickvd
DevNet Resident
Posts: 1027
Joined: Thu Mar 10, 2005 5:27 pm
Location: Southern Ontario
Contact:

Post by nickvd »

Is it really worth supporting the .001% that are still using Opera 7?

Edit: You're not testing your regex against anything....
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Post by JAB Creations »

The shares of people using Opera 7 are off-topic to this thread.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

You passed only the pattern but not the subject to ereg().
You want it to not match Opera/7 and to not match Opera 7 -> !ereg() && !ereg()
You could use a pattern but you didn't. The pattern would be: Opera / or space 7
ereg is deprecated, use preg_match instead.

try

Code: Select all

if ( !preg_match('!Opera[/\s]7!', $_SERVER['HTTP_USER_AGENT']) ) {
	require 'includes-noscript.php';
}
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Post by JAB Creations »

Thank you volka, this works great!

My site works great in Opera 7+, works good enough in Opera 4/5, and only currently has a menu issue with absolute positioning in Opera 3.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

You might be interested in http://de2.php.net/get_browser
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

I have a little code snippet in either coding critique or code snippets that might be helpful to you as well. If not, there is always phpSniff.
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Post by JAB Creations »

Thanks Everah, go ahead and post it or message it (whichever is fine). I'm dealing with such specific issues that scripts don't usually help but I'll still take a look. :)
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Don't be lazy JAB, using the search function you'll be able to find it in 10 seconds.
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Post by JAB Creations »

Oh well I've got all the issues on my mind browser-related covered thus far. I just have to document what I've done to deal with those issues. Thanks though...
Post Reply