Auto Theme Switch — PHP syntax ?
-
Hi,
I’m using a modified Blix theme, which behaves differently in different browser/platform combos. The cleanest solution appears to be a bit of browser sniffing PHP dropped into the header, e.g.,
‘<?php if (eregi(“MSIE”,getenv(“HTTP_USER_AGENT”)) ||
eregi(“Internet Explorer”,getenv(“HTTP_USER_AGENT”))) { ?><link rel=”stylesheet” type=”text/css” href=”<?php bloginfo(‘stylesheet_directory’); ?>/style-ie.css”/>
<?php } else { ?>
<link rel=”stylesheet” type=”text/css” href=”<?php bloginfo(‘stylesheet_directory’); ?>/style.css”/>
<?php } ?>’This works fine except when I try to add an elseif statement for Mac detection:
‘<?php elseif (eregi(“MACOS”,getenv(“HTTP_USER_AGENT”)) ||
eregi(“Safari”,getenv(“HTTP_USER_AGENT”))) { ?><link rel=”stylesheet” type=”text/css” href=”<?php bloginfo(‘stylesheet_directory’); ?>/stylemac.css”/>’This stops any theme from loading. The browser displays a blank screen.
This is probably just a glitch in my syntax, but I don’t know enough about PHP to locate the problem.
Can any of you PHP jocks out there spot the problem?
Thanks in advance.
- The topic ‘Auto Theme Switch — PHP syntax ?’ is closed to new replies.