PHP Manual
Prev |  | Next

# htmlspecialchars

htmlspecialchars -- Convert special characters to HTML entities

## Description

`string htmlspecialchars`(string string);

Certain characters have special significance in HTML, and should be represented by HTML entities if they are to preserve their meanings. This function returns a string with these conversions made.

This function is useful in preventing user-supplied text from containing HTML markup, such as in a message board or guest book application.

At present, the translations that are done are:

- '&' (ampersand) becomes '&amp;'

- '"' (double quote) becomes '&quot;'

- '<' (less than) becomes '&lt;'

- '>' (greater than) becomes '&gt;'

Note that this functions does not translate anything beyond what is listed above. For full entity translation, see htmlentities().

See also htmlentities() and nl2br().

Prev | Home | Next
htmlentities | Up | implode