Skip to main content

Posts

Showing posts with the label laravel get all headers from request

Laravel Get Headers From Request Example

Hi Dev, In this blog ,I Will learn you how to get header in laravel. I will show example of laravel get headers from request you can easliy laravel get all headers from request. I will explain laravel get all headers. I can blow you can easily get headers from request in laravel this example. Exmaple:1 Here In this exmaple laravel Get headers from request to a header method /** * Show the application dashboard. * * @return \Illuminate\Contracts\Support\Renderable */ public function index(Request $request) { $headers = $request->header('connection'); dd($headers); } Output : "keep-alive" Exmaple:2 Here In this exmaple laravel get headers from request using a request builder to a header method /** * Show the application dashboard. * * @return \Illuminate\Contracts\Support\Renderable */ public function index() { $headers = \Request::header(); dd($headers); } Output : array:13 [ "host" => array:1 [ 0 => "localho