PHP Laravel 5 - Get User Agent Value from Request


In this article, i am going to show you how to get user agent from user request in laravel 5.4 application. PHP Laravel framework did several update from their other version. we will see how we can get user agent value from request object. Laravel 5 introduce Request object that provide user request details.

So, let's see bellow two way to get user agent value form laravel 5 application.

One:

/**

* Show the application dashboard.

*

* @return \Illuminate\Http\Response

*/

public function create(Request $request)

{

$agent = $request->header('user-agent');

dd($agent);

}

two:

/**

* Show the application dashboard.

*

* @return \Illuminate\Http\Response

*/

public function create()

{

$agent = Request::header('user-agent');

dd($agent);

}

Try above example...


June 17, 2017 | 1615 Viewer | Category : PHP Laravel

Related Posts: