-
Notifications
You must be signed in to change notification settings - Fork 2
Request: withUri Example
Terry L edited this page Jun 20, 2020
·
3 revisions
Shieldon\Psr7\Request
Extends Message.
Returns an instance with the provided URI.
-
param
UriInterface
uri*
New request URI to use. -
param
string
preserveHost*
Preserve the original state of the Host header. -
return
static
Example:
$request = new Request('GET', 'https://terryl.in/zh/', '', [], '1.1');
$newRequest = $request->withUri(new Uri('https://play.google.com'));
$newRequest2 = $newRequest->withUri(new Uri('https://www.facebook.com'), true);
echo $newRequest->getUri()->getHost();
// Outputs: play.google.com
echo $newRequest2->getUri()->getHost();
// Outputs: terryl.in
composer require shieldon/psr-http
Shieldon PSR HTTP implementation written by Terry L. from Taiwan.