O'Reilly logo

Programming PHP, 3rd Edition by Peter MacIntyre, Kevin Tatroe, Rasmus Lerdorf

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

htmlspecialchars

Synopsis

string htmlspecialchars(string string[,
   int style[, string encoding[, bool double_encode]]])

Converts characters in string that have special meaning in HTML and returns the resulting string. A subset of all HTML entities covering the most common characters is used to perform the translation. If supplied, style determines the manner in which quotes are translated. The characters translated are:

  • Ampersand (&) becomes &

  • Double quotes (") become "

  • Single quote (') becomes '

  • Less than sign (<) becomes &lt;

  • Greater than sign (>) becomes &gt;

The possible values for style are the same as those for htmlentities. If supplied, encoding determines the final encoding for the characters. The possible values for encoding are the same as those for htmlentities. When double_encode is turned off, PHP will not encode existing htmlentities.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required