News from the Field
A channel with tips on modern AI development. Join!
110 of 410 menu
◀ ▶

The htmlentities Function

The htmlentities function converts characters into corresponding HTML entities. See examples for better understanding.

The function is similar to htmlspecialchars, however, unlike it, converts all characters for which an HTML entity exists.

Syntax

htmlentities(string $string, int $flags = ENT_COMPAT, ?string $encoding = null, bool $double_encode = true): string

Example

Let's convert a string with tags:

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

Code execution result:

'<b>text</b>'

Example

Let's convert a string with an ampersand:

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

Code execution result:

'test: &'

See Also

← →
↑
English▼
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline