PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular

strip_tags

Tags: PHP 5.x PHP 7.x PHP 8.x

strip_tags — Strip HTML and PHP tags from a string.

Description

strip_tags(
    string $string,
array|string|null $allowed_tags = null
): string
This function tries to return a string with all NULL bytes, HTML and PHP tags stripped from a given string.

Note: HTML comments and PHP tags are also stripped. This is hardcoded and can not be changed with allowed_tags.

Parameters

string
The input string.
allowed_tags
You can use the optional second parameter to specify tags which should not be stripped. These are either given as string, or as of PHP 7.4.0, as array. Refer to the example below regarding the format of this parameter.

Return Values

Returns the stripped string.