1. Technology
You can opt-out at any time. Please refer to our privacy policy for contact information.

Htmlspecialchars () PHP Function


Definition: Htmlspecialchars () is used to convert special characters to HTML entities so their meanings are preserved. It will return the altered string. It is phrased as: htmlspecialchars ( string, quote_style ,charset ). Both quote_stype and charset are optional, and do not need to be included.
Also Known As: HTML Special Characters
 $convert = htmlspecialchars("<a href='http://www.mysite.com'>Links</a>"); 
 echo $convert; 
'&' (ampersand) becomes '&'
'"' (double quote) becomes '"' when ENT_NOQUOTES is not set.
''' (single quote) becomes ''' only when ENT_QUOTES is set.
'<' (less than) becomes '<'
'>' (greater than) becomes '>'
Related Video
Using PHP With HTML
Basic PHP Syntax
  1. About.com
  2. Technology
  3. PHP / MySQL
  4. PHP Functions
  5. htmlspecialchars - HTML in PHP - Htmlspecialchars PHP

©2014 About.com. All rights reserved.