Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

PHP Useragent on Ifastnet?


ghost's Avatar
0 0

I was following a tutorial because I'm trying to learn PHP, and it was showing me how to get the users Useragent. So here's my code:

if (strpos($_SERVER['HTTP_USER_AGENT], 'MSIE') !==FALSE {
      echo 'You are using Internet Explorer.<br />';
}
?>```
So why does that not output anything when I load my page?, its just a blank screen? Thanks
end3r

ghost's Avatar
0 0

I take it you're using another user agent?

if (strpos($_SERVER['HTTP_USER_AGENT], 'MSIE') !==FALSE) { // Don't forget, you missed a closing brace
echo 'You are using Internet Explorer.<br />';
} else 
{
echo "You're not using internet explorer!<br />";
}
?>```

That should work now, regardless of browser.

What happened is the parser found the statement to be false, so therefore ignored the echo statement within the curley  braces :).

Good luck.
-Jay.

ghost's Avatar
0 0

This question's thread was deleted during roll back. I solved the problem then