URL::current()

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

Table of Contents
  1. Description
  2. Example

Description

URL::current(array|bool|string $query = [], bool|string $hash = true): string;

This method returns the full URL address along with its query and hash.

Example

$url = new URL('http://127.0.0.1/foo/bar/baz?foo=bar#baz');

echo $url->current; // Returns `'http://127.0.0.1/foo/bar/baz?foo=bar#baz'`
echo $url->current(false, false); // Returns `'http://127.0.0.1/foo/bar/baz'`
echo $url->current(true, false); // Returns `'http://127.0.0.1/foo/bar/baz?foo=bar'`
echo $url->current(false, true); // Returns `'http://127.0.0.1/foo/bar/baz#baz'`
echo $url->current([], false); // Returns `'http://127.0.0.1/foo/bar/baz?foo=bar'`
echo $url->current(['bar' => 'baz', 'foo' => 1], 'qux'); // Returns `'http://127.0.0.1/foo/bar/baz?bar=baz&foo=1#qux'`

URL::current()

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