URL::offsetSet()

Sets a URL data.

Table of Contents
  1. Description
  2. Example

Description

URL::offsetSet(mixed $key, mixed $value): void;

This method is a requirement to be able to implement the ArrayAccess interface and aims to make the object data modifiable using array access syntax. You won’t use this method directly, it will be executed automatically when you try to set a URL data with array access syntax. This method sets and normalize a URL data. If the data already exists, this method will override the data with that normalized value.

Example

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

$url['path'] = '/foo/bar/baz';

echo $url['path']; // Returns `'foo/bar/baz'`
echo $url; // Returns `'http://127.0.0.1/foo/bar/baz'`

$url['path'] = "//foo/bar\\baz/";

echo $url['path']; // Returns `'foo/bar/baz'`
echo $url; // Returns `'http://127.0.0.1/foo/bar/baz'`

URL::current()

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

URL::offsetSet()

Sets a URL data.