mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-20 10:58:54 +00:00

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@91440 c90b9560-bf6c-de11-be94-00142212c4b1
116 lines
3.9 KiB
XML
116 lines
3.9 KiB
XML
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!-- $Revision: 1.3 $ -->
|
|
<!-- splitted from ./en/functions/strings.xml, last change in rev 1.2 -->
|
|
<refentry id="function.htmlspecialchars">
|
|
<refnamediv>
|
|
<refname>htmlspecialchars</refname>
|
|
<refpurpose>
|
|
Convert special characters to HTML entities
|
|
</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<methodsynopsis>
|
|
<type>string</type><methodname>htmlspecialchars</methodname>
|
|
<methodparam><type>string</type><parameter>string</parameter></methodparam>
|
|
<methodparam choice="opt"><type>int</type><parameter>quote_style</parameter></methodparam>
|
|
<methodparam choice="opt"><type>string</type><parameter>charset</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
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 some of these
|
|
conversions made; the translations made are those most
|
|
useful for everyday web programming. If you require all HTML
|
|
character entities to be translated, use
|
|
<function>htmlentities</function> instead.
|
|
</para>
|
|
<simpara>
|
|
This function is useful in preventing user-supplied text from
|
|
containing HTML markup, such as in a message board or guest book
|
|
application. The optional second argument, quote_style, tells
|
|
the function what to do with single and double quote characters.
|
|
The default mode, ENT_COMPAT, is the backwards compatible mode
|
|
which only translates the double-quote character and leaves the
|
|
single-quote untranslated. If ENT_QUOTES is set, both single and
|
|
double quotes are translated and if ENT_NOQUOTES is set neither
|
|
single nor double quotes are translated.
|
|
</simpara>
|
|
<para>
|
|
The translations performed are:
|
|
<itemizedlist>
|
|
<listitem>
|
|
<simpara>
|
|
'&' (ampersand) becomes '&amp;'
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
'"' (double quote) becomes '&quot;' when ENT_NOQUOTES
|
|
is not set.
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
''' (single quote) becomes '&#039;' only when
|
|
ENT_QUOTES is set.
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
'<' (less than) becomes '&lt;'
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
'>' (greater than) becomes '&gt;'
|
|
</simpara>
|
|
</listitem>
|
|
</itemizedlist>
|
|
<example>
|
|
<title><function>htmlspecialchars</function> example</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
$new = htmlspecialchars("<a href='test'>Test</a>", ENT_QUOTES);
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
Note that this function does not translate anything beyond what
|
|
is listed above. For full entity translation, see
|
|
<function>htmlentities</function>. Support for the optional
|
|
second argument was added in PHP 3.0.17 and PHP 4.0.3.
|
|
</para>
|
|
<para>
|
|
The third argument defines character set used in conversion. The
|
|
default character set is ISO-8859-1. Support for this third argument was
|
|
added in PHP 4.1.0.
|
|
</para>
|
|
<para>
|
|
See also <function>get_html_translation_table</function>,
|
|
<function>htmlentities</function> and <function>nl2br</function>.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"../../../../manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
-->
|