Hallo Martin,
ich habe folgendes in meine website eingebaut
<?php
if (strpos($HTTP_USER_AGENT,"Mozilla")) {
echo("<link rel="stylesheet" type="text/css" href="../src/style_mozilla.css" />\n");
} else {
echo("<link rel="stylesheet" type="text/css" href="../src/style.css" />\n");
}
?>PHP funktioniert alles wunderbar, globalVars sind aktiviert, aber das script funktioniert nicht. es liefert immer false, d.h. der standard-style-sheet wird geladen, anstatt dem speziellen für mozilla (bzw firefox).
Ich denke mal, dass das "Mozilla" am Anfang von $HTTP_USER_AGENT vorkommt, also an Position 0. Leider wird diese 0 als etwas Unwahres interpretiert, als funktioniert es nicht.
So geht es richtig:
if(strpos($HTTP_USER_AGENT,"Mozilla") !== false)
{
# OK, Mozilla
}
else
{
# Kein Mozilla
}
Dadurch wird geprüft, ob
strpos($HTTP_USER_AGENT,"Mozilla") wirklich vom Typ her "false" ergibt. Und das trifft hier auf eine 0 nicht zu.
Es ist aber generell keine gute Idee, register_globals zu aktivieren. Schalte es besser ab!
Viele Grüße
Patrick Canterino