To::URL()

Converts private file path to public URL, or decodes URL special characters.

Table of Contents
  1. Description
  2. Example

Description

To::URL(?string $value, bool $raw = false): ?string;

This method decodes URL special characters so that the result can be displayed as raw text.

Unlike From::URL() that does not convert public URL prefix to private file path prefix, this method converts private file path prefix to public URL prefix, and will also normalize the \ characters to /. To convert public URL to private file path, use To::path() method instead.

Example

$value = To::URL('foo+bar%2Bbaz'); // Returns `'foo bar+baz'`
$value = To::URL('foo+bar%2Bbaz', true); // Returns `'foo+bar+baz'`
$value = To::URL('.\lot\asset\book.pdf'); // Returns `'http://127.0.0.1/lot/asset/book.pdf'`

To::URL()

Converts private file path to public URL, or decodes URL special characters.

To::entity()

Converts characters to their corresponding HTML entities.

To::file()

Converts current value to a safe file name.

To::path()

Converts public URL to private file path.