<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->

<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>
  &warn.deprecated.feature-7-2-0.removed-8-0-0;
 </para>
 <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>stripos</function></entry>
      <entry><function>mb_stripos</function></entry>
     </row>
     <row>
      <entry>2</entry>
      <entry><function>strripos</function></entry>
      <entry><function>mb_strripos</function></entry>
     </row>
     <row>
      <entry>2</entry>
      <entry><function>strstr</function></entry>
      <entry><function>mb_strstr</function></entry>
     </row>
     <row>
      <entry>2</entry>
      <entry><function>stristr</function></entry>
      <entry><function>mb_stristr</function></entry>
     </row>
     <row>
      <entry>2</entry>
      <entry><function>strrchr</function></entry>
      <entry><function>mb_strrchr</function></entry>
     </row>
     <row>
      <entry>2</entry>
      <entry><function>substr_count</function></entry>
      <entry><function>mb_substr_count</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:"~/.phpdoc/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
-->

