htmlspecialchars

(FW >= 1.0)

htmlspecialchars - Convert special characters to HTML entities

Description

string htmlspecialchars( string $data )
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.

Parameters

data

string requiring formatting.

The translations performed are:

  • '&' (ampersand) becomes '&'
  • '"' (double quote) becomes '"'
  • "'" (single quote) becomes ''' 
  • '<' (less than) becomes '&lt;'
  • '>' (greater than) becomes '&gt;'

Return Value

string with certain characters replaced

Examples

<? 

$$new = htmlspecialchars("<a href='test'>Test</a>");
echo($new);
//&lt;a href=&#039;test&#039;&gt;Test&lt;/a&gt;

?>