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

Uri\Rfc3986\Uri::equals

PHP function Edit on GitHub ✎

(PHP 8 >= 8.5.0)

Check if two URIs are equivalent

Description

Uri\Rfc3986\Uri::equals(Uri\Rfc3986\Uri $uri, Uri\UriComparisonMode $comparisonMode = Uri\UriComparisonMode::ExcludeFragment): bool

Checks if two URIs are equivalent.

Parameters

uri

URI to compare the current URI 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.

Return Values

Returns true if the two URIs are equivalent, or false otherwise.

Examples

Uri\Rfc3986\Uri::equals basic example

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

var_dump($uri1->equals($uri2));
?>

The above example will output:

output
bool(true)

See Also

  • Uri\WhatWg\Url::equals

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