samedi 9 mai 2020

Combining multiple strpos() in an if () statement

I'm trying to make added user agent stay on a page. If user agent is not detected, then redirect.

This code works

$useragent = $_SERVER['HTTP_USER_AGENT'];

if (strpos($useragent, "useragent") === false) {
  header("Location: http://google.com/");
}

So I tried to add multiple user agent like this but didn't work.

$useragent = $_SERVER['HTTP_USER_AGENT'];

if (
    strpos($useragent, "agent1") === false ||
    strpos($useragent, "agent2") === false ||
    strpos($useragent, "agent2") === false
) {
      header("Location: http://google.com/");
}

Aucun commentaire:

Enregistrer un commentaire