This package is deprecated Please consider using an stable alternative for any production code.

URI references

is_absolute

available since version 1.1.0

The is_absolute function tells whether the given URI object represents an absolute URI.

<?php

use League\Uri\Http;
use function League\Uri\is_absolute;

is_absolute(Http::createFromServer($_SERVER)); //returns true
is_absolute(Http::createFromString("/🍣🍺")); //returns false

is_absolute_path

available since version 1.1.0

The is_absolute_path function tells whether the given URI object represents an absolute URI path.

<?php

use League\Uri\Http;
use function League\Uri\is_absolute_path;

is_absolute_path(Http::createFromServer($_SERVER)); //returns false
is_absolute_path(Http::createFromString("/🍣🍺")); //returns true

is_network_path

available since version 1.1.0

The is_network_path function tells whether the given URI object represents an network path URI.

<?php

use League\Uri\Http;
use function League\Uri\is_absolute_path;

is_network_path(Http::createFromString("//example.com/toto")); //returns true
is_network_path(Http::createFromString("/🍣🍺")); //returns false

is_relative_path

available since version 1.1.0

The is_relative_path function tells whether the given URI object represents a relative path.

<?php

use League\Uri\Http;
use function League\Uri\is_relative_path;

is_relative_path(Http::createFromString("🏳️‍🌈")); //returns true
is_relative_path(Http::createFromString("/🍣🍺")); //returns false

is_same_document

available since version 1.1.0

The is_same_document function tells whether the given URI object represents the same document.

<?php

use League\Uri\Http;
use function League\Uri\is_same_document;

is_same_document(
    Http::createFromString("example.com?foo=bar#🏳️‍🌈"),
    Http::createFromString("exAMpLE.com?foo=bar#🍣🍺")
); //returns true

uri_reference

this function is deprecated as of version 1.1.0 and will be remove in the next major release.

This function analyzes the submitted URI object and returns an associative array containing information regarding the URI-reference as per RFC3986.

Parameters

Returns Values

An associative array is returned. The following keys are always present within the array and their content is always a boolean:

<?php

use GuzzleHttp\Psr7\Uri as GuzzleUri;
use League\Uri\Schemes\Http;
use function League\Uri\Modifiers\uri_reference;

$guzzle_uri = new GuzzleUri("//스타벅스코리아.com/how/are/you?foo=baz");
$alt_uri = Http::createFromString("//xn--oy2b35ckwhba574atvuzkc.com/how/are/you?foo=baz#bar");

var_dump(uri_reference($guzzle_uri));
//displays
// array(5) {
//   'absolute_uri' => bool(false)
//   'network_path' => bool(true)
//   'absolute_path' => bool(false)
//   'relative_path' => bool(false)
//   'same_document' => bool(false)
// }

var_dump(uri_reference($guzzle_uri, $alt_uri));
//displays
// array(5) {
//   'absolute_uri' => bool(false)
//   'network_path' => bool(true)
//   'absolute_path' => bool(false)
//   'relative_path' => bool(false)
//   'same_document' => bool(true)  //can be true only if a base URI is provided
// }