1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
|
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.2 $ -->
<chapter xml:id="mbstring.overload" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>
Function Overloading Feature
</title>
<para>
You might often find it difficult to get an existing PHP application
to work in a given multibyte environment. This happens because most
PHP applications out there are written with the standard string
functions such as <function>substr</function>, which are known to
not properly handle multibyte-encoded strings.
</para>
<para>
mbstring supports a 'function overloading' feature which enables
you to add multibyte awareness to such an application without
code modification by overloading multibyte counterparts on
the standard string functions. For example,
<function>mb_substr</function> is called instead of
<function>substr</function> if function overloading is enabled.
This feature makes it easy to port applications that only support
single-byte encodings to a multibyte environment in many cases.
</para>
<para>
To use function overloading, set
<literal>mbstring.func_overload</literal> in &php.ini; to a
positive value that represents a combination of bitmasks specifying
the categories of functions to be overloaded. It should be set
to 1 to overload the <function>mail</function> function. 2 for string
functions, 4 for regular expression functions. For example,
if it is set to 7, mail, strings and regular expression functions will
be overloaded. The list of overloaded functions are shown below.
<table>
<title>Functions to be overloaded</title>
<tgroup cols="3">
<thead>
<row>
<entry>value of mbstring.func_overload</entry>
<entry>original function</entry>
<entry>overloaded function</entry>
</row>
</thead>
<tbody>
<row>
<entry>1</entry>
<entry><function>mail</function></entry>
<entry><function>mb_send_mail</function></entry>
</row>
<row>
<entry>2</entry>
<entry><function>strlen</function></entry>
<entry><function>mb_strlen</function></entry>
</row>
<row>
<entry>2</entry>
<entry><function>strpos</function></entry>
<entry><function>mb_strpos</function></entry>
</row>
<row>
<entry>2</entry>
<entry><function>strrpos</function></entry>
<entry><function>mb_strrpos</function></entry>
</row>
<row>
<entry>2</entry>
<entry><function>substr</function></entry>
<entry><function>mb_substr</function></entry>
</row>
<row>
<entry>2</entry>
<entry><function>strtolower</function></entry>
<entry><function>mb_strtolower</function></entry>
</row>
<row>
<entry>2</entry>
<entry><function>strtoupper</function></entry>
<entry><function>mb_strtoupper</function></entry>
</row>
<row>
<entry>2</entry>
<entry><function>substr_count</function></entry>
<entry><function>mb_substr_count</function></entry>
</row>
<row>
<entry>4</entry>
<entry><function>ereg</function></entry>
<entry><function>mb_ereg</function></entry>
</row>
<row>
<entry>4</entry>
<entry><function>eregi</function></entry>
<entry><function>mb_eregi</function></entry>
</row>
<row>
<entry>4</entry>
<entry><function>ereg_replace</function></entry>
<entry><function>mb_ereg_replace</function></entry>
</row>
<row>
<entry>4</entry>
<entry><function>eregi_replace</function></entry>
<entry><function>mb_eregi_replace</function></entry>
</row>
<row>
<entry>4</entry>
<entry><function>split</function></entry>
<entry><function>mb_split</function></entry>
</row>
</tbody>
</tgroup>
</table>
</para>
<note>
<para>
It is not recommended to use the function overloading option in
the per-directory context, because it's not confirmed yet to be
stable enough in a production environment and may lead to undefined
behaviour.
</para>
</note>
</chapter>
<!-- 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
-->
|