-
Notifications
You must be signed in to change notification settings - Fork 2
Message: getHeader Example
Terry L edited this page Jun 20, 2020
·
3 revisions
Shieldon\Psr7\Message
Retrieves a message header value by the given case-insensitive name.
-
param
string
name*
Case-insensitive header field name. -
return
array
An array of string values as provided for the given. Return empty array if the header dosn't exist.
Example:
$useragent = $this->message->getHeader('user-agent');
print(print_r($useragent, true));
/* Outputs:
Array
(
[0] => Mozilla/5.0 (Windows NT 10.0; Win64; x64)
)
*/
$useragent = $this->message->getHeader('does-not-exist');
print(print_r($useragent, true));
/* Outputs:
Array()
*/
composer require shieldon/psr-http
Shieldon PSR HTTP implementation written by Terry L. from Taiwan.