Skip to content

Uri: withHost Example

Terry L edited this page Jun 20, 2020 · 3 revisions
Clone this wiki locally

Shieldon\Psr7\Uri

withHost($host)

Return an instance with the specified host.

  • param string host * The hostname to use with the new instance.
  • return static

Example:

echo $uri->getHost();
// Outputs: example.com

$url = $uri->withHost('terryl.in');

echo $uri->getHost();
// Outputs: terryl.in