YouTip LogoYouTip

Func String Htmlspecialchars Decode

## 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:
← Func String HtmlspecialcharsFunc String Htmlentities β†’