Identifica qual navegador está usando
$useragent = $_SERVER['HTTP_USER_AGENT'];
if (preg_match('|MSIE ([0-9].[0-9]{1,2})|',$useragent,$matched)) {
$browser_version=$matched[1];
$browser = 'IE';
$hoje = date("d/m/Y");
} elseif (preg_match( '|Opera/([0-9].[0-9]{1,2})|',$useragent,$matched)) {
$browser_version=$matched[1];
$browser = 'Opera';
$hoje = date("d/m/Y");
} elseif(preg_match('|Firefox/([0-9\.]+)|',$useragent,$matched)) {
$browser_version=$matched[1];
$browser = 'Firefox';
$hoje = date("d/m/Y");
} elseif(preg_match('|Chrome/([0-9\.]+)|',$useragent,$matched)) {
$browser_version=$matched[1];
$browser = 'Chrome';
$hoje = date("Y-m-d");
} elseif(preg_match('|Safari/([0-9\.]+)|',$useragent,$matched)) {
$browser_version=$matched[1];
$hoje = date("d/m/Y");
$browser = 'Safari';
} else {
// browser not recognized!
$browser_version = 0;
$browser= 'other';
}
if (preg_match('|MSIE ([0-9].[0-9]{1,2})|',$useragent,$matched)) {
$browser_version=$matched[1];
$browser = 'IE';
$hoje = date("d/m/Y");
} elseif (preg_match( '|Opera/([0-9].[0-9]{1,2})|',$useragent,$matched)) {
$browser_version=$matched[1];
$browser = 'Opera';
$hoje = date("d/m/Y");
} elseif(preg_match('|Firefox/([0-9\.]+)|',$useragent,$matched)) {
$browser_version=$matched[1];
$browser = 'Firefox';
$hoje = date("d/m/Y");
} elseif(preg_match('|Chrome/([0-9\.]+)|',$useragent,$matched)) {
$browser_version=$matched[1];
$browser = 'Chrome';
$hoje = date("Y-m-d");
} elseif(preg_match('|Safari/([0-9\.]+)|',$useragent,$matched)) {
$browser_version=$matched[1];
$hoje = date("d/m/Y");
$browser = 'Safari';
} else {
// browser not recognized!
$browser_version = 0;
$browser= 'other';
}
Comentários
Postar um comentário