<HTML ><HEAD ><TITLE >htmlentities</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="PHP Manual" HREF="index.html"><LINK REL="UP" TITLE="String functions" HREF="ref.strings.html"><LINK REL="PREVIOUS" TITLE="html_entity_decode" HREF="function.html-entity-decode.html"><LINK REL="NEXT" TITLE="htmlspecialchars" HREF="function.htmlspecialchars.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=ISO-8859-1"></HEAD ><BODY CLASS="refentry" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >PHP Manual</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.html-entity-decode.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.htmlspecialchars.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="function.htmlentities" ></A >htmlentities</H1 ><DIV CLASS="refnamediv" ><A NAME="AEN89600" ></A ><P > (PHP 3, PHP 4 )</P >htmlentities -- Convert all applicable characters to HTML entities </DIV ><DIV CLASS="refsect1" ><A NAME="AEN89603" ></A ><H2 >Description</H2 >string <B CLASS="methodname" >htmlentities</B > ( string string [, int quote_style [, string charset]])<BR ></BR ><P > This function is identical to <A HREF="function.htmlspecialchars.html" ><B CLASS="function" >htmlspecialchars()</B ></A > in all ways, except with <B CLASS="function" >htmlentities()</B >, all characters which have HTML character entity equivalents are translated into these entities. </P ><P > Like <A HREF="function.htmlspecialchars.html" ><B CLASS="function" >htmlspecialchars()</B ></A >, the optional second <TT CLASS="parameter" ><I >quote_style</I ></TT > parameter lets you define what will be done with 'single' and "double" quotes. It takes on one of three constants with the default being <TT CLASS="constant" ><B >ENT_COMPAT</B ></TT >: <DIV CLASS="table" ><A NAME="AEN89624" ></A ><P ><B >Table 1. Available <TT CLASS="parameter" ><I >quote_style</I ></TT > constants</B ></P ><TABLE BORDER="1" CLASS="CALSTABLE" ><THEAD ><TR ><TH ALIGN="LEFT" VALIGN="MIDDLE" >Constant Name</TH ><TH ALIGN="LEFT" VALIGN="MIDDLE" >Description</TH ></TR ></THEAD ><TBODY ><TR ><TD ALIGN="LEFT" VALIGN="MIDDLE" ><TT CLASS="constant" ><B >ENT_COMPAT</B ></TT ></TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" >Will convert double-quotes and leave single-quotes alone.</TD ></TR ><TR ><TD ALIGN="LEFT" VALIGN="MIDDLE" ><TT CLASS="constant" ><B >ENT_QUOTES</B ></TT ></TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" >Will convert both double and single quotes.</TD ></TR ><TR ><TD ALIGN="LEFT" VALIGN="MIDDLE" ><TT CLASS="constant" ><B >ENT_NOQUOTES</B ></TT ></TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" >Will leave both double and single quotes unconverted.</TD ></TR ></TBODY ></TABLE ></DIV > </P ><P > Support for the optional <TT CLASS="parameter" ><I >quote</I ></TT > parameter was added in PHP 4.0.3. </P ><P > Like <A HREF="function.htmlspecialchars.html" ><B CLASS="function" >htmlspecialchars()</B ></A >, it takes an optional third argument which defines character set used in conversion. Support for this argument was added in PHP 4.1.0. Presently, the ISO-8859-1 character set is used as the default. </P ><P > If you're wanting to decode instead (the reverse) you can use <A HREF="function.html-entity-decode.html" ><B CLASS="function" >html_entity_decode()</B ></A >. </P ><P > See also <A HREF="function.html-entity-decode.html" ><B CLASS="function" >html_entity_decode()</B ></A >, <A HREF="function.get-html-translation-table.html" ><B CLASS="function" >get_html_translation_table()</B ></A >, <A HREF="function.htmlspecialchars.html" ><B CLASS="function" >htmlspecialchars()</B ></A >, <A HREF="function.nl2br.html" ><B CLASS="function" >nl2br()</B ></A >, and <A HREF="function.urlencode.html" ><B CLASS="function" >urlencode()</B ></A >. </P ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="function.html-entity-decode.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.htmlspecialchars.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >html_entity_decode</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="ref.strings.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >htmlspecialchars</TD ></TR ></TABLE ></DIV ></BODY ></HTML >