Files
archived-doc-pt-br/reference/mbstring/overloading.xml
Leonardo Lara Rodrigues 60e0f4e31b sync lines with en rev
2025-11-28 09:44:52 -03:00

148 lines
4.9 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- EN-Revision: 3f1dbc451b313fb1ec8058f24c1beccf55fce316 Maintainer: leonardolara Status: ready --><!-- CREDITS: fernandowobeto, leonardolara -->
<chapter xml:id="mbstring.overload" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>
Recurso de Sobrecarga de Funções
</title>
&warn.deprecated.feature-7-2-0.removed-8-0-0;
<para>
É possível que frequentemente sejam encontradas dificuldades ao fazer com que uma aplicação PHP existente
funcione em um ambiente multibyte específico. Isso acontece porque a maioria
das aplicações PHP por aí são escritas com funções de string padrão
como <function>substr</function>, que são conhecidas por
não lidar corretamente com strings codificadas em multibyte.
</para>
<para>
mbstring suporta um recurso de 'sobrecarga de funções' que permite
adicionar suporte a multibyte a uma aplicação dessas sem
modificar o código, sobrecarregando as contrapartes multibyte
das funções de string padrão. Por exemplo,
<function>mb_substr</function> é chamada em vez de
<function>substr</function> se a sobrecarga de funções estiver ativada.
Esse recurso facilita a migração de aplicações que suportam apenas
codificações de byte único para um ambiente multibyte em muitos casos.
</para>
<para>
Para usar a sobrecarga de funções, defina
<literal>mbstring.func_overload</literal> no &php.ini; para um
valor positivo que represente uma combinação de máscaras de bits especificando
as categorias de funções a serem sobrecarregadas. Deve ser definido
como 1 para sobrecarregar a função <function>mail</function>, 2 para funções de string,
4 para funções de expressão regular. Por exemplo,
se for definido como 7, as funções de correio, strings e expressões regulares serão
sobrecarregadas. A lista de funções sobrecarregadas é mostrada abaixo.
<table>
<title>Funções a serem sobrecarregadas</title>
<tgroup cols="3">
<thead>
<row>
<entry>valor de mbstring.func_overload</entry>
<entry>função original</entry>
<entry>função sobrecarregada</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>
Não é recomendado usar a opção de sobrecarga de funções no
contexto por diretório, porque ainda não foi confirmado como
sendo estável o suficiente em um ambiente de produção e pode levar a um
comportamento indefinido.
</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
-->