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

Uri\WhatWg\Url::getPath

PHP function Edit on GitHub ✎

(PHP 8 >= 8.5.0)

Retrieve the path component

Description

Uri\WhatWg\Url::getPath(): string

Retrieves the path component.

Parameters Parameters

Return Values

Returns the path component as a String.

Examples

Uri\WhatWg\Url::getPath basic example

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

echo $url->getPath();
?>

The above example will output:

output
/foo/bar

See Also

  • Uri\WhatWg\Url::withPath
  • Uri\Rfc3986\Uri::getRawPath
  • Uri\Rfc3986\Uri::getPath

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