LonghornPHP 2026

Uri\WhatWg\Url::equals

(PHP 8 >= 8.5.0)

Uri\WhatWg\Url::equalsCheck if two URLs are equivalent

Descrizione

public function Uri\WhatWg\Url::equals(Uri\WhatWg\Url $url, Uri\UriComparisonMode $comparisonMode = Uri\UriComparisonMode::ExcludeFragment): bool

Checks if two URLs are equivalent.

Elenco dei parametri

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.

Valori restituiti

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

Esempi

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));
?>

Il precedente esempio visualizzerà:

bool(true)

Vedere anche:

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top