To::text()

Converts current value to plain text.

Table of Contents
  1. Description
  2. Example

Description

To::text(?string $value, array|string $keep = [], bool $break = false): ?string;

This method converts current value to plain text. This method is an alias for function w().

Example

$value = To::text(""); // Returns `null`
$value = To::text('!@#$%^&*()'); // Returns `'!@#$%^&*()'`
$value = To::text(" \n\r\t"); // Returns `""`
$value = To::text('foo bar baz'); // Returns `'foo bar baz'`
$value = To::text('foo-bar-baz'); // Returns `'foo bar baz'`
$value = To::text('.foo-bar-baz'); // Returns `'foo bar baz'`
$value = To::text('<foo>foo</foo> <bar>bar</bar> <baz>baz</baz> &hearts; <!-- qux -->'); // Returns `'foo bar baz &hearts;'`
$value = To::text('<foo>foo</foo> <bar>bar</bar> <baz>baz</baz> &hearts; <!-- qux -->', ['bar', 'baz']); // Returns `'foo <bar>bar</bar> <baz>baz</baz> &hearts;'`
$value = To::text('<foo>foo</foo> <bar>bar</bar> <baz>baz</baz> &hearts; <!-- qux -->', 'bar,baz'); // Returns `'foo <bar>bar</bar> <baz>baz</baz> &hearts;'`

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.

To::text()

Converts current value to plain text.