I'm using this JS code to know what browser is user using for.
<script> document.write(navigator.appName); </script>
And I want to get this navigator.appName to php code to use it like this:
if ($appName == "Internet Explorer") { // blabla }
How can I do it?
Google Chrome Chrome's user agent switcher is part of its Developer Tools. Open them by clicking the menu button and selecting More Tools > Developer Tools. You can also use press Ctrl+Shift+I on your keyboard.
The get_browser() function in PHP is an inbuilt function that is used to tell the user about the browser's capabilities. This function looks up the user's browscap. ini file and returns the capabilities of the user's browser.
In this snippet, we'll see how to get user-agent from user request in laravel. $agent = $request->header('user-agent'); $agent = request()->header('user-agent'); $agent = Request::header('user-agent'); All of these code snippet return the User-agent in Laravel.
The variable we are interested in right now is $_SERVER['HTTP_USER_AGENT'] . Note: $_SERVER is a special reserved PHP variable that contains all web server information. It is known as a superglobal. See the related manual page on superglobals for more information.
Use the native PHP $_SERVER['HTTP_USER_AGENT']
variable instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With