PHP code example of tr33m4n / url-object

1. Go to this page and download the library: Download tr33m4n/url-object library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

tr33m4n / url-object example snippets


$comparator = \tr33m4n\UriComparator\Comparator::compare(
    'https://example.com:1234',
    'https://another-example.com:1234?this=test&another=something',
    \League\Uri\Http::createFromString('https://example.com:1234'),
    \League\Uri\Uri::createFromString('https://another-example.com:1234?this=test&another=something')
    // An instance of `\Psr\Http\Message\UriInterface`
    // etc...
);

var_dump($comparator->matchPort());
var_dump($comparator->matchHost());
var_dump($comparator->matchScheme());
var_dump($comparator->matchPath());
// bool(true)
// bool(false)
// bool(true)
// bool(true)

// From array of URI's
$comparator = \tr33m4n\UriComparator\Comparator::compareArray([
    'https://example.com:1234',
    'https://another-example.com:1234?this=test&another=something',
    \League\Uri\Http::createFromString('https://example.com:1234'),
    \League\Uri\Uri::createFromString('https://another-example.com:1234?this=test&another=something')
]);