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

Uri\WhatWg\Url::getQuery

PHP function Edit on GitHub ✎

(PHP 8 >= 8.5.0)

Retrieve the query component

Description

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

Retrieves the query component.

Parameters Parameters

Return Values

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

Examples

Uri\WhatWg\Url::getQuery basic example

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

echo $url->getQuery();
?>

The above example will output:

output
foo/bar

See Also

  • Uri\WhatWg\Url::withQuery
  • Uri\Rfc3986\Uri::getRawQuery
  • Uri\Rfc3986\Uri::getQuery

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