cvs: /phpdoc/functions strings.sgml

From: Date: Mon, 22 Nov 1999 19:24:10 +0000
Subject: cvs: /phpdoc/functions strings.sgml
Groups: php.dev 
Request: Send a blank email to php-dev+get-12934@lists.php.net to get a copy of this message
eschmid Mon Nov 22 14:24:10 1999 EDT Modified files: /phpdoc/functions strings.sgml Log: Found an workaround for special characters. Should be encoded as entity references. Index: phpdoc/functions/strings.sgml diff -u phpdoc/functions/strings.sgml:1.27 phpdoc/functions/strings.sgml:1.28 --- phpdoc/functions/strings.sgml:1.27 Mon Nov 22 05:56:19 1999 +++ phpdoc/functions/strings.sgml Mon Nov 22 14:24:09 1999 @@ -406,6 +406,71 @@ </refsect1> </refentry> + <refentry id="function.get-html-translation-table"> + <refnamediv> + <refname>get_html_translation_table</refname> + <refpurpose> + Returns the translation table used by + <function>htmlspecialchars</function> and + <function>htmlentities</function> + </refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <funcsynopsis> + <funcdef>string + <function>get_html_translation_table</function> + </funcdef> + <paramdef>int <parameter>table</parameter></paramdef> + </funcsynopsis> + <para> + <function>get_html_translation_table</function> will return the + translation table that is used internally for + <function>htmlspecialchars</function> and + <function>htmlentities</function>. Ther are two new defines + (<parameter>HTML_ENTITIES</parameter>, + <parameter>HTML_SPECIALCHARS</parameter>) that allow you to + specify the table you want. + + <example> + <title>Translation Table Example</title> + <programlisting role="php"> +$trans = get_html_translation_table (HTML_ENTITIES); +$str = "Hallo & &lt;Frau> & Krämer"; +$encoded = strtr ($str, $trans); + </programlisting> + </example> + + The <literal>$encoded</literal> variable will now contain: "Hallo + &<sgmltag>amp</sgmltag>; + &<sgmltag>lt</sgmltag>;Frau&<sgmltag>gt</sgmltag>; + &<sgmltag>amp</sgmltag>; Kr&<sgmltag>auml</sgmltag>;mer". + </para> + <para> + The cool thing is using <function>array_flip</function> to change + the direction of the translation. + <informalexample> + <programlisting role="php"> +$trans = array_flip ($trans); +$original = strtr ($str, $trans); + </programlisting> + </informalexample> + The content of <literal>$original</literal> would be: "Hallo & + &lt;Frau> & Krämer". + <note> + <para> + This function was added in PHP 4.0. + </para> + </note> + </para> + <para> + See also: <function>htmlspecialchars</function>, + <function>htmlentities</function>, <function>strtr</function>, + and <function>array_flip</function>. + </para> + </refsect1> + </refentry> + <refentry id="function.get-meta-tags"> <refnamediv> <refname>get_meta_tags</refname> @@ -1801,7 +1866,31 @@ </programlisting> </example></para> <para> - See also <function>ereg_replace</function>.</para> + <function>strtr</function> can be called with only two + arguments. If called with two arguments it behaves in a new way: + <parameter>from</parameter> then has to be an array that contains + string -> string pairs that will be replaced in the source + string. <function>strtr</function> will always look for the + longest possible match first and will *NOT* try to replace stuff + that it has already worked on. + <para> + Examples: + <informalexample> + <programlisting role="php"> +$trans = array ("hello" => "hi", "hi" => "hello"); +echo strtr("hi all, I said hello", $trans) . "\n"; + </programlisting> + </informalexample> + This will show: "hello all, I said hi", + </para> + <note> + <simpara> + This feature (two arguments) was added in PHP 4.0. + </simpara> + </note> + <para> + See also <function>ereg_replace</function>. + </para> </refsect1> </refentry>

« previous php.dev (#12934) next »