php8.5
Home/ Manual/ rfc3986 / uri/ Uri\Rfc3986\Uri::getPort

Uri\Rfc3986\Uri::getPort

PHP function Edit on GitHub ✎

(PHP 8 >= 8.5.0)

Retrieve the normalized port component

Description

Uri\Rfc3986\Uri::getPort(): int|null

Retrieves the normalized port component.

Parameters Parameters

Return Values

Returns the normalized port component as an Integer if the port component exists, null is returned otherwise.

Examples

Uri\Rfc3986\Uri::getPort basic example

php
<?php
$uri = new \Uri\Rfc3986\Uri("https://example.com:443");

echo $uri->getPort();
?>

The above example will output:

output
443

See Also

  • Uri\Rfc3986\Uri::withPort
  • Uri\WhatWg\Url::getPort

Source: reference/uri/uri/rfc3986/uri/getport.xml · from the official PHP manual (php/doc-en)