php8.5
Home/ Manual/ whatwg / url/ Uri\WhatWg\Url::getFragment

Uri\WhatWg\Url::getFragment

PHP function Edit on GitHub ✎

(PHP 8 >= 8.5.0)

Retrieve the fragment component

Description

Uri\WhatWg\Url::getFragment(): string|null

Retrieves the fragment component.

Parameters Parameters

Return Values

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

Examples

Uri\WhatWg\Url::getFragment basic example

php
<?php
$url = new \Uri\WhatWg\Url("https://example.com#foo");

echo $url->getFragment();
?>

The above example will output:

output
foo

See Also

  • Uri\WhatWg\Url::withFragment
  • Uri\Rfc3986\Uri::getRawFragment
  • Uri\Rfc3986\Uri::getFragment

Source: reference/uri/uri/whatwg/url/getfragment.xml · from the official PHP manual (php/doc-en)