## PHP String Functions
* [addcslashes()](func-string-addcslashes.html)
* [addslashes()](func-string-addslashes.html)
* [bin2hex()](func-string-bin2hex.html)
* [chop()](func-string-chop.html)
* [chr()](func-string-chr.html)
* [chunk_split()](func-string-chunk-split.html)
* [convert_cyr_string()](func-string-convert-cyr-string.html)
* [convert_uudecode()](func-string-convert-uudecode.html)
* [convert_uuencode()](func-string-convert-uuencode.html)
* [count_chars()](func-string-count-chars.html)
* [crc32()](func-string-crc32.html)
* [crypt()](func-string-crypt.html)
* (func-string-echo.html)
* [explode()](func-string-explode.html)
* [fprintf()](func-string-fprintf.html)
* [get_html_translation_table()](func-string-get-html-translation-table.html)
* [hebrev()](func-string-hebrev.html)
* [hebrevc()](func-string-hebrevc.html)
* [hex2bin()](func-string-hex2bin.html)
* [html_entity_decode()](func-string-html-entity-decode.html)
* [htmlentities()](func-string-htmlentities.html)
* [htmlspecialchars()](func-string-htmlspecialchars.html)
* [htmlspecialchars_decode()](func-string-htmlspecialchars-decode.html)
* [implode()](func-string-implode.html)
* [join()](func-string-join.html)
* [lcfirst()](func-string-lcfirst.html)
* [levenshtein()](func-string-levenshtein.html)
* [localeconv()](func-string-localeconv.html)
* [ltrim()](func-string-ltrim.html)
* [md5()](func-string-md5.html)
* [md5_file()](func-string-md5-file.html)
* [metaphone()](func-string-metaphone.html)
* [money_format()](func-string-money-format.html)
* [nl_langinfo()](func-string-nl-langinfo.html)
* [nl2br()](func-string-nl2br.html)
* [number_format()](func-string-number-format.html)
* [ord()](func-string-ord.html)
* [parse_str()](func-string-parse-str.html)
* (func-string-print.html)
* [printf()](func-string-printf.html)
* [quoted_printable_decode()](func-string-quoted-printable-decode.html)
* [quoted_printable_encode()](func-string-quoted-printable-encode.html)
* [quotemeta()](func-string-quotemeta.html)
* [rtrim()](func-string-rtrim.html)
* [setlocale()](func-string-setlocale.html)
* [sha1()](func-string-sha1.html)
* [sha1_file()](func-string-sha1-file.html)
* [similar_text()](func-string-similar-text.html)
* [soundex()](func-string-soundex.html)
* [sprintf()](func-string-sprintf.html)
* [sscanf()](func-string-sscanf.html)
* [str_contains()](func-string-str-contains.html)
* [str_ends_with()](func-string-str-ends-with.html)
* [str_getcsv()](func-string-str-getcsv.html)
* [str_ireplace()](func-string-str-ireplace.html)
* [str_pad()](func-string-str-pad.html)
* [str_repeat()](func-string-str-repeat.html)
* [str_replace()](func-string-str-replace.html)
* [str_rot13()](func-string-str-rot13.html)
* [str_shuffle()](func-string-str-shuffle.html)
* [str_split()](func-string-str-split.html)
* [str_starts_with()](func-string-str-starts-with.html)
* [str_word_count()](func-string-str-word-count.html)
* [strcasecmp()](func-string-strcasecmp.html)
* [strchr()](func-string-strchr.html)
* [strcmp()](func-string-strcmp.html)
* [strcoll()](func-string-strcoll.html)
* [strcspn()](func-string-strcspn.html)
* [strip_tags()](func-string-strip-tags.html)
* [stripcslashes()](func-string-stripcslashes.html)
* [stripslashes()](func-string-stripslashes.html)
* [stripos()](func-string-stripos.html)
* [stristr()](func-string-stristr.html)
* [strlen()](func-string-strlen.html)
* [strnatcasecmp()](func-string-strnatcasecmp.html)
* [strnatcmp()](func-string-strnatcmp.html)
* [strncasecmp()](func-string-strncasecmp.html)
* [strncmp()](func-string-strncmp.html)
* [strpbrk()](func-string-strpbrk.html)
* [strpos()](func-string-strpos.html)
* [strrchr()](func-string-strrchr.html)
* [strrev()](func-string-strrev.html)
* [strripos()](func-string-strripos.html)
* [strrpos()](func-string-strrpos.html)
* [strspn()](func-string-strspn.html)
* [strstr()](func-string-strstr.html)
* [strtod()](func-string-strtod.html)
* [strtok()](func-string-strtok.html)
* [strtolower()](func-string-strtolower.html)
* [strtoupper()](func-string-strtoupper.html)
* [strtr()](func-string-strtr.html)
* [substr()](func-string-substr.html)
* [substr_compare()](func-string-substr-compare.html)
* [substr_count()](func-string-substr-count.html)
* [substr_replace()](func-string-substr-replace.html)
* [trim()](func-string-trim.html)
* [ucfirst()](func-string-ucfirst.html)
* [ucwords()](func-string-ucwords.html)
* [vfprintf()](func-string-vfprintf.html)
* [vprintf()](func-string-vprintf.html)
* [vsprintf()](func-string-vsprintf.html)
* [wordwrap()](func-string-wordwrap.html)
## Definition and Usage
The htmlspecialchars_decode() function converts some predefined HTML entities to characters.
The predefined entities are:
* & becomes & (ampersand)
* " becomes " (double quote)
* ' becomes ' (single quote)
* < becomes (greater than)
This function is the opposite of htmlspecialchars().
**Note:** If the string to be decoded contains valid HTML, this function will NOT decode existing HTML tags.
| Parameter | Description |
|---|---|
| string | Required. Specifies the string to decode |
| flags | Optional. Specifies how to handle quotes and which document type to use. Available quote styles: * ENT_COMPAT - Default. Decodes only double quotes * ENT_QUOTES - Decodes both single and double quotes * ENT_NOQUOTES - Does not decode any quotes * Additional flags for specifying the document type: * ENT_HTML401 - Default. Handle code as HTML 4.01 * ENT_HTML5 - Handle code as HTML 5 * ENT_XML1 - Handle code as XML 1 * ENT_XHTML - Handle code as XHTML |
| encoding | Optional. Specifies the encoding to use. Default is "UTF-8". |
## Technical Details
| Return Value: | Returns the decoded string on success. Returns FALSE if the encoding parameter is not valid. |
|---|---|
| PHP Version: | 5.1.0+ |
## Example 1
Convert some predefined HTML entities to characters:
```php
<?php
$str = "This is some <b>bold</b> text.";
echo htmlspecialchars_decode($str);
echo "
";
echo htmlspecialchars_decode($str, ENT_QUOTES);
echo "
";
echo htmlspecialchars_decode($str, ENT_NOQUOTES);
?>
```
The output of the code above will be:
```html
This is some bold text.
This is some bold text.
This is some bold text.
```
## Example 2
This example demonstrates how to decode double quotes using different flags:
```php
<?php
$str = 'Jane "has" a little lamb.';
echo htmlspecialchars_decode($str, ENT_COMPAT);
echo "
";
echo htmlspecialchars_decode($str, ENT_QUOTES);
echo "
";
echo htmlspecialchars_decode($str, ENT_NOQUOTES);
?>
```
The output of the code above will be:
```html
Jane "has" a little lamb.
Jane "has" a little lamb.
Jane "has" a little lamb.
```
(
(
[/Previous: htmlspecialchars()](/php/func-string-htmlspecialchars.html) [Next: implode()](/php/func-string-implode.html)[!(
Copyright Β© 2014-2025 rnunoob.com All Rights Reserved. ICP Filing Number:
π Categories
- β‘ JavaScript (1589)
- π PHP (872)
- π Python3 (810)
- π HTML (691)
- βοΈ C# (650)
- π Python (594)
- β Java (552)
- βοΈ PyTorch (534)
- π§ Linux (472)
- βοΈ C (432)
- π¦ jQuery (406)
- π¨ CSS (377)
- π XML (259)
- π¦ jQuery UI (231)
- π― Bootstrap (220)
- βοΈ C++ (215)
- π °οΈ Angular (205)
- π HTML DOM (201)
- π΄ Redis (188)
- π Web Building (142)
- π Vue.js (141)
- π R (131)
- πΌ Pandas (124)
- ποΈ SQL (105)
- βοΈ Docker (86)
- βοΈ TypeScript (73)
- βοΈ Highcharts (70)
- π AI Agent (70)
- βοΈ React (68)
- π Node.js (65)
- βοΈ Machine Learning (60)
- π Git (59)
- π΅ Go (58)
- π Markdown (58)
- π’ NumPy (55)
- π§ͺ Flask (54)
- βοΈ Scala (53)
- ποΈ SQLite (52)
- π JSTL (52)
- βοΈ VS Code (51)
- π MongoDB (49)
- π Perl (48)
- π Ruby (47)
- π Matplotlib (47)
- βοΈ Uncategorized (46)
- π Swift (46)
- ποΈ PostgreSQL (46)
- βοΈ Data Structures (46)
- π Playwright (46)
- π iOS (45)
- ποΈ MySQL (44)
- βοΈ LangChain (43)
- π FastAPI (40)
- βοΈ Ionic (38)
- π Design Patterns (37)
- βοΈ Eclipse (37)
- π¨ CSS3 (34)
- π Lua (34)
- βοΈ Codex (34)
- πΈ Django (32)
- βοΈ OpenCV (32)
- π Rust (31)
- π JSP (31)
- βοΈ Claude Code (31)
- π Pillow (30)
- βοΈ OpenCode (28)
- π AI Skills (27)
- π Flutter (26)
- π Maven (26)
- π¨ Tailwind CSS (25)
- π§ TensorFlow (25)
- π Servlet (24)
- π Dart (23)
- π Assembly (23)
- βοΈ Memcached (22)
- βοΈ SVG (22)
- βοΈ Electron (22)
- π NLP (22)
- π Regex (21)
- π Android (20)
- π£ Kotlin (19)
- π Julia (19)
- π SOAP (17)
- π Selenium (17)
- π PowerShell (17)
- π Sass (16)
- π HTTP (16)
- π Zig (15)
- π AI (15)
- π AJAX (14)
- π Swagger (14)
- βοΈ Scikit-learn (13)
- βοΈ ECharts (13)
- βοΈ Chart.js (13)
- βοΈ Cursor (13)
- βοΈ SciPy (12)
- π RDF (12)
- π Ollama (12)
- π Next.js (12)
- π Plotly Dash (12)
- π JSON (11)
- π RESTful API (11)
- π WSDL (9)
- βοΈ CMake (8)
- π Firebug (7)
- π Nginx (6)
- βΈοΈ Kubernetes (6)
- π Jupyter (6)
- π LaTeX (4)
- π UniApp (4)
- ποΈ SQL Server (1)
YouTip