URL::offsetGet()

Returns the normalized URL data.

Table of Contents
  1. Description
  2. Example

Description

URL::offsetGet(mixed $key): mixed;

This method is a requirement to be able to implement the ArrayAccess interface and aims to make the object data accessible using array access syntax. You won’t use this method directly, it will be executed automatically when you try to get an URL data with array access syntax. This method gets an URL data using its key. If the key does not exist in the data, this method returns null.

Example

$url = new URL('http://127.0.0.1:8080');

test($url->port); // Returns `':8080'`
test($url['port']); // Returns `8080`
test($url['query']); // Returns `null`

URL::current()

Returns the full URL address along with its query and hash.

URL::offsetGet()

Returns the normalized URL data.