0

I am upgrading from php 5.5 and this worked, but not sure what I can use now to detect the google chrome browser?

function is_chrome()
{
    return(eregi("chrome", $_SERVER['HTTP_USER_AGENT']));
}

if(is_chrome())
{ 
  $chrome = 'You are using Google Chrome Browser.';
} else{
  $chrome = 'hide';
}
Dan
  • 1
  • " Warning This function was DEPRECATED in PHP 5.3.0, and REMOVED in PHP 7.0.0. Alternatives to this function include: preg_match() " http://php.net/manual/en/function.ereg.php –  Dec 15 '16 at 03:23
  • I will see if I can find an example with preg_match(). I appreciate the tip. – Dan Dec 15 '16 at 03:26
  • if you just use get_browser() no regular expression is required –  Dec 15 '16 at 03:28
  • I am trying that out right now! :) – Dan Dec 15 '16 at 03:29
  • You can those answer - http://stackoverflow.com/questions/3047894/how-to-detect-google-chrome-as-the-user-agent-using-php – IqbalBary Dec 15 '16 at 03:29
  • echo $_SERVER['HTTP_USER_AGENT']; $browser = get_browser(); print_r($browser); – Dan Dec 15 '16 at 03:31

0 Answers0