Click to See Complete Forum and Search --> : Strange HTTP_USER_AGENT effects?


Anon
04-24-2002, 03:03 PM
I've learned a lot from the board here, but have come across a stumper...

I'm running PHP4 on an NT box running Netscape Enterprise Server. $HTTP_USER_AGENT didn't work for me, but $HTTP_SERVER_VARS["HTTP_USER_AGENT"] did on a simple test page.

When I tried to incorporate this into this function I borrowed from WebmasterBase...

function inAgent($agent) {
global $HTTP_USER_AGENT;
$notAgent = strpos($HTTP_USER_AGENT,$agent) === false;
return !$notAgent;
}

Then all I get when I load the .php is a blank HTML document with html and body tags???? -- even though there is a lot of html code elsewhere on the page.

If I remove the global line, then at least the page loads again, but it appears that the script does not run, as an echo $browser returns a blank line.

Anon
04-25-2002, 12:27 PM
Okay, solved part of this myself. Can anyone tell me why this doesn't work...

if inAgent('Mozilla') {
echo "Mozilla ";
}

but this does...

if (inAgent('Mozilla')) {
echo "Mozilla ";
}

The top example makes all the html in my page disappear. I find I am having to parenthesize nearly all my statements this way.