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

Uri\Rfc3986\Uri::getHost

PHP function Edit on GitHub ✎

(PHP 8 >= 8.5.0)

Retrieve the normalized host component

Description

Uri\Rfc3986\Uri::getHost(): string|null

Retrieves the normalized host component.

Parameters Parameters

Return Values

Returns the normalized host component as a String if the host component exists, null is returned otherwise.

Examples

Uri\Rfc3986\Uri::getHost basic example

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

echo $uri->getHost();
?>

The above example will output:

output
example.com

See Also

  • Uri\Rfc3986\Uri::getRawHost
  • Uri\Rfc3986\Uri::withHost
  • Uri\WhatWg\Url::getAsciiHost
  • Uri\WhatWg\Url::getUnicodeHost

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