Uri\WhatWg\Url::equals
(PHP 8 >= 8.5.0)
Uri\WhatWg\Url::equals — Check if two URLs are equivalent
Description
public function Uri\WhatWg\Url::equals(Uri\WhatWg\Url
$url, Uri\UriComparisonMode $comparisonMode = Uri\UriComparisonMode::ExcludeFragment): boolChecks if two URLs are equivalent.
Parameters
url
URL to compare the current URL against.
comparisonMode
Whether the fragment component is taken into account of the comparison
(Uri\UriComparisonMode::IncludeFragment) or not
(Uri\UriComparisonMode::ExcludeFragment). By default, the fragment is excluded.
Examples
Example #1 Uri\WhatWg\Url::equals() basic example
<?php
$url1 = new \Uri\WhatWg\Url("https://example.com");
$url2 = new \Uri\WhatWg\Url("HTTPS://example.com");
var_dump($url1->equals($url2));
?>The above example will output:
bool(true)
See Also
- Uri\Rfc3986\Uri::equals() - Check if two URIs are equivalent
来源:PHP Documentation Group · 作者与贡献记录 · CC BY 3.0。离线整理了版式、链接和媒体显示。
