Skip to content

Uri: withPort Example

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

Shieldon\Psr7\Uri

withPort($port)

Return an instance with the specified port.

  • param int|null port * The port to use with the new instance; a null value removes the port information.
  • return static

Example:

echo $uri->getPort();
// Outputs: 8888

$uri = $uri->withPort(443);
echo $uri->getPort();
// Outputs: 443

$uri = $uri->withPort(null);
echo $uri->getPort();
// Outputs:
Clone this wiki locally