Reputation: 261
i want to get all header parameters value which i used in postman headers tab.
i passed value in header like : 'lancode','deviceId', etc..
i try
$lancode = $request->header('lancode');
but this code is does not work for me.. other solution please
Upvotes: 2
Views: 4550
Reputation: 28529
You can get specific header with
`$_SERVER["HTTP_" . strtoupper(str_replace("-","_",$header_name))];`
In your case use $_SERVER['HTTP_LANCODE'];
For example set a header test
with sss
, then the print_r($_SREVER)
, output
Array
(
[HTTP_TEST] => ssss
...
)
Note: updace your header name, then replace -
with _
then append HTTP_
to the header name when access from $_SERVER
variable.
rfc3875: 4.1.18. Protocol-Specific Meta-Variables
Meta-variables with names beginning with "HTTP_" contain values read from the client request header fields, if the protocol used is HTTP. The HTTP header field name is converted to upper case, has all occurrences of
"-"
replaced with"_"
and has "HTTP_" prepended to give the meta-variable name.
Upvotes: 3
Reputation: 181
you can use
$getHeaders = apache_request_headers();
and then you can store header value like
$lancode = $getHeaders['lancode'];
it's work for me.
Upvotes: 5