111 of 410 menu

The html_entity_decode Function

The html_entity_decode function converts HTML entities to their corresponding characters. See examples for better understanding.

Syntax

html_entity_decode(string $string, int $flags = ENT_COMPAT, ?string $encoding = null): string

Example

Let's convert a string with tags:

<?php $str = '<b>text</b>'; $res = html_entity_decode($str); echo $res; ?>

Code execution result:

'<b>text</b>'

Example

Let's convert a string with an ampersand:

<?php $str = 'test: &'; $res = html_entity_decode($str); echo $res; ?>

Code execution result:

'test: &'

See Also

byenru