“PHP Get User Agent” Code-Antworten

PHP Get User Agent

$_SERVER['HTTP_USER_AGENT']
Friendly Hawk

PHP Get Browser

function get_browser_name($user_agent){
    $t = strtolower($user_agent);
    $t = " " . $t;
    if     (strpos($t, 'opera'     ) || strpos($t, 'opr/')     ) return 'Opera'            ;   
    elseif (strpos($t, 'edge'      )                           ) return 'Edge'             ;   
    elseif (strpos($t, 'chrome'    )                           ) return 'Chrome'           ;   
    elseif (strpos($t, 'safari'    )                           ) return 'Safari'           ;   
    elseif (strpos($t, 'firefox'   )                           ) return 'Firefox'          ;   
    elseif (strpos($t, 'msie'      ) || strpos($t, 'trident/7')) return 'Internet Explorer';
    return 'Unkown';
}
echo get_browser_name($_SERVER['HTTP_USER_AGENT']);//Chrome
Friendly Hawk

Ähnliche Antworten wie “PHP Get User Agent”

Fragen ähnlich wie “PHP Get User Agent”

Weitere verwandte Antworten zu “PHP Get User Agent” auf PHP

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen