-
Notifications
You must be signed in to change notification settings - Fork 1
Message: withAddedHeader Example
Terry L edited this page Jun 20, 2020
·
3 revisions
Shieldon\Psr7\Message
Return an instance with the specified header appended with the given value.
-
param
string
name*
Case-insensitive header field name. -
param
string|array
value*
Header value(s) -
return
static
Existing values for the specified header will be maintained. The new value(s) will be appended to the existing list. If the header did not exist previously, it will be added.
Example:
$message = $message->withHeader('foo', 'bar');
echo $message->getHeaderLine('foo');
// Outputs: bar
$message = $message->withAddedHeader('foo', 'baz');
echo $message->getHeaderLine('foo');
// Outputs: bar
$message = $message->withAddedHeader('foo2', 'baz');
echo $message->getHeaderLine('foo2');
// Outputs: baz
composer require shieldon/psr-http
Shieldon PSR HTTP implementation written by Terry L. from Taiwan.