User agent, extract OS and browser from string

前端 未结 3 1778
难免孤独
难免孤独 2021-01-13 09:48

I\'d like to extract full the OS name and browser from the user agent string. How can I do this?

3条回答
  •  春和景丽
    2021-01-13 10:00

    There's also a built-in function in PHP to achieve this and more: get_browser().

    $agent = get_browser();
    echo $agent->platform;
    echo $agent->parent; // or $agent->browser . $agent->version
    

提交回复
热议问题