cvs: phpdoc /en/appendices migration.xml migration4.xml phpdevel.xml reserved.constants.core.xml reserved.constants.standard.xml resources.xml
tokens.xml

From: Date: Wed, 20 Nov 2002 12:19:11 +0000
Subject: cvs: phpdoc /en/appendices migration.xml migration4.xml phpdevel.xml reserved.constants.core.xml reserved.constants.standard.xml resources.xml
tokens.xml
Groups: php.doc 
Request: Send a blank email to phpdoc+get-969349827@lists.php.net to get a copy of this message
thomasgm Wed Nov 20 07:19:11 2002 EDT Modified files: /phpdoc/en/appendices tokens.xml resources.xml reserved.constants.standard.xml reserved.constants.core.xml phpdevel.xml migration4.xml migration.xml Log: i'm right?

Index: phpdoc/en/appendices/tokens.xml diff -u phpdoc/en/appendices/tokens.xml:1.7 phpdoc/en/appendices/tokens.xml:1.8 --- phpdoc/en/appendices/tokens.xml:1.7 Thu Oct 3 15:00:33 2002 +++ phpdoc/en/appendices/tokens.xml Wed Nov 20 07:19:11 2002 @@ -1,17 +1,18 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.7 $ --> +<!-- $Revision: 1.8 $ --> <appendix id="tokens"> - <title>List of Parser Tokens</title> + <title>Lista dos Símbolos od Parse</title> <para> - Various parts of the PHP language are represented internally by types like - T_SR. PHP outputs identifiers like this one in parse errors, like - <literal>"Parse error: unexpected T_SR, expecting ',' or ';' in script.php on line 10."</literal> + V&aacute;rias partes da linguagem PHP s&atilde;o representadas internamente por + tipos como T_SR. Como estas sa&iacute;das de identificadores do PHP nos + erros do parse, como <literal>"Parse error: unexpected T_SR, expecting ',' or ';' in + script.php on line 10."</literal> </para> <para> - You're supposed to know what T_SR means. For everybody who doesn't - know that, here is a table with those identifiers, PHP-syntax and - references to the appropriate places in the manual. + Você supostamente já deve sar o que T_SR significa. Para quem + não sabe, aqui vai uma tabela de seus identificadores, sintaxe-PHP + e as referências apropriadas colocadas no manual. </para> <table> <title>Tokens</title> Index: phpdoc/en/appendices/resources.xml diff -u phpdoc/en/appendices/resources.xml:1.27 phpdoc/en/appendices/resources.xml:1.28 --- phpdoc/en/appendices/resources.xml:1.27 Thu Sep 5 16:19:04 2002 +++ phpdoc/en/appendices/resources.xml Wed Nov 20 07:19:11 2002 @@ -1,23 +1,23 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.27 $ --> +<!-- $Revision: 1.28 $ --> <appendix id="resource"> - <title>List of Resource Types</title> + <title>Lsita de Tipos de Recursos</title> <para> - The following is a list of functions which create, use or destroy - PHP resources. The function <function>is_resource</function> can be - used to determine if a variable is a resource and - <function>get_resource_type</function> will return the type of - resource it is. + A seguir h&aacute; uma lista de fun&ccedil;&otilde;es que criam, usam e destr&oacute;em + recursos do PHP. A fun&ccedil;&atilde;o <function>is_resource</function> podem + ser usadas para determinar se a vari&aacute;vel &eacute; um recurso e + o <function>get_resource_type</function> ir&aacute; retornar o tipo + de recurso que est&aacute; sendo usado. <table> - <title>Resource Types</title> + <title>Tipos de Recursos</title> <tgroup cols="5"> <thead> <row> - <entry>Resource Type Name</entry> - <entry>Created By</entry> - <entry>Used By</entry> - <entry>Destroyed By</entry> - <entry>Definition</entry> + <entry>Nome do Tipo de Recurso</entry> + <entry>Criado por</entry> + <entry>Usado por</entry> + <entry>Destro&iacute;do por</entry> + <entry>Defini&ccedil;&atilde;o</entry> </row> </thead> <tbody> Index: phpdoc/en/appendices/reserved.constants.standard.xml diff -u phpdoc/en/appendices/reserved.constants.standard.xml:1.4 phpdoc/en/appendices/reserved.constants.standard.xml:1.5 --- phpdoc/en/appendices/reserved.constants.standard.xml:1.4 Thu Jul 25 07:14:06 2002 +++ phpdoc/en/appendices/reserved.constants.standard.xml Wed Nov 20 07:19:11 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.4 $ --> +<!-- $Revision: 1.5 $ --> <!-- DOCNOTE: some constants listed here are also there at reference/info/constants.xml. Further decision is needed @@ -8,13 +8,13 @@ deleted from here to have a consistent standard constants list. --> <refentry id="reserved.constants.standard"> <refnamediv> - <refname>Standard Predefined Constants</refname> - <refpurpose>Constants defined in PHP by default</refpurpose> + <refname>Constantes Padr&otilde;es Pr&eacute;-definidas</refname> + <refpurpose>Constantes definidas no PHP por padr&atilde;o</refpurpose> </refnamediv> <refsect1> - <title>Description</title> + <title>Descri&ccedil;&atilde;o</title> <simpara> - These constants are defined in PHP by default. + Estas constantes s&atilde;o definidas por padr&atilde;o no PHP. </simpara> <variablelist> <varlistentry> Index: phpdoc/en/appendices/reserved.constants.core.xml diff -u phpdoc/en/appendices/reserved.constants.core.xml:1.2 phpdoc/en/appendices/reserved.constants.core.xml:1.3 --- phpdoc/en/appendices/reserved.constants.core.xml:1.2 Fri Apr 19 09:25:30 2002 +++ phpdoc/en/appendices/reserved.constants.core.xml Wed Nov 20 07:19:11 2002 @@ -1,15 +1,15 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <refentry id="reserved.constants.core"> <refnamediv> - <refname>Core Predefined Constants</refname> - <refpurpose>Constants defined in the PHP core, Zend, and SAPI modules</refpurpose> + <refname>Constantes Pr&eacute;-definidas do N&uacute;cleo</refname> + <refpurpose>Constantes definidas no n&uacute;cleo do PHP, Zend, e m&oacute;dulos SAPI</refpurpose> </refnamediv> <refsect1> - <title>Description</title> + <title>Descri&ccedil;&atilde;o</title> <simpara> - These constants are defined by the PHP core. This includes PHP, - the Zend engine, and SAPI modules. + Estas constantes s&atilde;o definidas pelo n&uacute;cleo do PHP. Isto + inclui o PHP, a Zend engine, e os m&oacute;dulos SAPI. </simpara> <variablelist> <varlistentry> Index: phpdoc/en/appendices/phpdevel.xml diff -u phpdoc/en/appendices/phpdevel.xml:1.20 phpdoc/en/appendices/phpdevel.xml:1.21 --- phpdoc/en/appendices/phpdevel.xml:1.20 Fri May 31 05:55:37 2002 +++ phpdoc/en/appendices/phpdevel.xml Wed Nov 20 07:19:11 2002 @@ -1,16 +1,16 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.20 $ --> +<!-- $Revision: 1.21 $ --> <appendix id="phpdevel"> - <title>Extending PHP</title> + <title>Estentendo o PHP</title> <simpara></simpara> <sect1 id="phpdevel-addfunc"> - <title>Adding functions to PHP</title> + <title>Adicionando fun&ccedil;&otilde;es ao PHP</title> <sect2 id="phpdevel-addfunc-prototype"> - <title>Function Prototype</title> + <title>Fun&ccedil;&atilde;o Prototype</title> <para> - All functions look like this: + Todas as fun&ccedil;&otilde;es separecem com esta: <programlisting role="c"> <![CDATA[ void php3_foo(INTERNAL_FUNCTION_PARAMETERS) { @@ -18,16 +18,18 @@ } ]]> </programlisting> - Even if your function doesn't take any arguments, this is how it is - called.</para></sect2> + Mesmo se sua fun&ccedil;&atilde;o n&atilde;o pegar nenhum argumento, &eacute; assim + que ela &eacute; chamada. + </para></sect2> <sect2 id="phpdevel-addfunc-args"> - <title>Function Arguments</title> + <title>Argumentos das fun&ccedil;&otilde;es</title> <para> - Arguments are always of type pval. This type contains a union - which has the actual type of the argument. So, if your function - takes two arguments, you would do something like the following at - the top of your function:</para> + Os argumentos s&atilde;o sempre do tipo pval. Este tipo cont&eacute;m a uni&atilde;o + que cont&eacute;m o tipo atual do argumento. Ent&atilde;o, se sua fun&ccedil;&atilde;o + pegar dois argumentos, voc&ecirc; faria algo como a seguir no topo + da sua fun&ccedil;&atilde;o: + </para> <para> <example> @@ -41,36 +43,39 @@ ]]> </programlisting> </example> + NOTA: Argumentos podem ser passados pelo valor ou pela refer&ecirc;ncia. + Em ambos os casos voc&ecirc; ir&aacute; precisar passar &amp;(pval *) para + o getParameters. Se voc&ecirc; quer checar se n'th foi + enviado por refer&ecirc;ncia ou n&atilde;o, voc&ecirc; pode usar a seguinte fun&ccedil;&atilde;o. + ParameterPassedByReference(ht,n). Isto ir&aacute; retornar 1 ou 0. + + </para> - NOTE: Arguments can be passed either by value or by reference. In - both cases you will need to pass &amp;(pval *) to getParameters. If - you want to check if the n'th parameter was sent to you by - reference or not, you can use the function, - ParameterPassedByReference(ht,n). It will return either 1 or 0.</para> - - <simpara> - When you change any of the passed parameters, whether they are - sent by reference or by value, you can either start over with the - parameter by calling pval_destructor on it, or if it's an ARRAY - you want to add to, you can use functions similar to the ones in - internal_functions.h which manipulate return_value as an ARRAY.</simpara> - - <simpara> - Also if you change a parameter to IS_STRING make sure you first - assign the new estrdup()'ed string and the string length, and only - later change the type to IS_STRING. If you change the string of a - parameter which already IS_STRING or IS_ARRAY you should run - pval_destructor on it first.</simpara></sect2> + <simpara> + Quando voc&ecirc; muda qualquer argumento passado por refer&ecirc;ncia, + se eles foram emitidos por refer&ecirc;ncia ou pelo valor, voc&ecirc; + pode come&ccedil;ar a partir do par&acirc;metro chamado pela pval_destructor, + ou se for um ARRAY que voc&ecirc; quer adicionar, voc&ecirc; pode usar + fun&ccedil;&otilde;es similares &agrave;s do arquivo internal_functions.h que + manipula o return_value como um ARRAY.</simpara> + + <simpara> + Tamb&eacute;m se voc&ecirc; mudar um par&acirc;metro para IS_STRING tenha + certeza de primeiro atribuir a string e o tamanho dela ao + estrdup()'ed, e somente mais tarde alterar o tipo para + IS_STRING. Se voc&ecirc; quiser alterar a string de um par&acirc;metro + que j&aacute; &eacute; IS_STRING ou IS_ARRAY voc&ecirc; deve rodar o pval_destructor + primeiro.</simpara></sect2> <sect2 id="phpdevel-addfunc-varargs"> - <title>Variable Function Arguments</title> + <title>Argumentos das Vari&aacute;veis de Fun&ccedil;&otilde;es</title> <para> - A function can take a variable number of arguments. If your function can - take either 2 or 3 arguments, use the following:</para> + Uma fun&ccedil;&atilde;o pode pegar um n&uacute;mero de vari&aacute;veis e argumentos. Se sua + fun&ccedil;&atilde;o precisa pegar 2 ou 3 argumentos, use as instru&ccedil;&otilde;es a seguir:</para> <para> <example> - <title>Variable function arguments</title> + <title>Argumentos das Vari&aacute;veis de Fun&ccedil;&otilde;es</title> <programlisting role="c"> <![CDATA[ pval *arg1, *arg2, *arg3; @@ -85,13 +90,13 @@ </example></para></sect2> <sect2 id="phpdevel-addfunc-using-args"> - <title>Using the Function Arguments</title> + <title>Usando os Argumentos das Fun&ccedil;&otilde;es</title> <para> - The type of each argument is stored in the pval type field. This - type can be any of the following: + O tipo de cada argumento é armazenado no campo do tipo pval. + Este tipo pode ser qualquer um dos seguintes: <table> - <title>PHP Internal Types</title> + <title>Tipos Internos do PHP</title> <tgroup cols="2"> <tbody> <row> @@ -104,7 +109,7 @@ </row> <row> <entry>IS_LONG</entry> - <entry>Long integer</entry> + <entry>Inteiro longo</entry> </row> <row> <entry>IS_ARRAY</entry> @@ -112,7 +117,7 @@ </row> <row> <entry>IS_EMPTY</entry> - <entry>None</entry> + <entry>Nenhum(a)</entry> </row> <row> <entry>IS_USER_FUNCTION</entry> @@ -120,7 +125,7 @@ </row> <row> <entry>IS_INTERNAL_FUNCTION</entry> - <entry>?? (if some of these cannot be passed to a function - delete)</entry> + <entry>?? (se alguma dessas n&atilde;o puder ser passada para uma fun&ccedil;&atilde;o - delete)</entry> </row> <row> <entry>IS_CLASS</entry> @@ -135,10 +140,10 @@ </table></para> <para> - If you get an argument of one type and would like to use it as - another, or if you just want to force the argument to be of a - certain type, you can use one of the following conversion - functions: + Se voc&ecirc; pegar um argumento de um tipo e quiser usar ele + como outro tipo, ou se voc&ecirc; somente quer for&ccedil;ar o argumento + a ser de um certo tipo, voc&ecirc; pode usar as seguintes fun&ccedil;&otilde;es + para convers&atilde;o: <programlisting role="c"> <![CDATA[ @@ -151,10 +156,10 @@ </programlisting></para> <simpara> - These function all do in-place conversion. They do not return anything.</simpara> + Estas fun&ccedil;&otilde;es fazem convers&otilde;es in-place. Elas n&atilde;o retornam nada.</simpara> <para> - The actual argument is stored in a union; the members are: + O argumento atual &eacute; armazenado na uni&atilde;o; os membros s&atilde;o: <itemizedlist> <listitem><simpara>IS_STRING: arg1-&gt;value.str.val</simpara></listitem> <listitem><simpara>IS_LONG: arg1-&gt;value.lval</simpara></listitem> @@ -162,45 +167,47 @@ </itemizedlist></para></sect2> <sect2 id="phpdevel-addfunc-memmgmt"> - <title>Memory Management in Functions</title> + <title>Gerenciamento de Mem&oacute;ria nas Fun&ccedil;&otilde;es</title> <simpara> - Any memory needed by a function should be allocated with either - emalloc() or estrdup(). These are memory handling abstraction - functions that look and smell like the normal malloc() and - strdup() functions. Memory should be freed with efree().</simpara> - - <simpara> - There are two kinds of memory in this program: memory which is - returned to the parser in a variable, and memory which you need for - temporary storage in your internal function. When you assign a - string to a variable which is returned to the parser you need to - make sure you first allocate the memory with either emalloc() or - estrdup(). This memory should NEVER be freed by you, unless you - later in the same function overwrite your original assignment - (this kind of programming practice is not good though).</simpara> - - <simpara> - For any temporary/permanent memory you need in your - functions/library you should use the three emalloc(), estrdup(), - and efree() functions. They behave EXACTLY like their counterpart - functions. Anything you emalloc() or estrdup() you have to efree() - at some point or another, unless it's supposed to stick around - until the end of the program; otherwise, there will be a memory - leak. The meaning of "the functions behave exactly like their - counterparts" is: if you efree() something which was not - emalloc()'ed nor estrdup()'ed you might get a segmentation - fault. So please take care and free all of your wasted memory.</simpara> - - <simpara> - If you compile with "-DDEBUG", PHP will print out a list of all - memory that was allocated using emalloc() and estrdup() but never - freed with efree() when it is done running the specified script.</simpara></sect2> + Toda mem&oacute;rai necess&aacute;ria para uma fun&ccedil;&atilde;o deve ser alocada no + emalloc() ou estrdup(). Estes eventos de mem&oacute;ria s&atilde;o abstratos + e se parecem com as fun&ccedil;&otilde;es normais como a malloc() e strdup(). + A mem&oacute;ria deve ser liberada com efree().</simpara> + + <simpara> + H&aacute; dois tipos de mem&oacute;ria neste programa: a mem&oacute;ria que &eacute; + retornada para o parser em uma vari&aacute;vel, e a mem&oacute;ria que &eacute; + temporariamente armazenada na sua fun&ccedil;&atilde;o interna. Quando + voc&ecirc; atribui uma string a uma vari&aacute;vel que &eacute; retornada ao + parser voc&ecirc; preicsa ter certeza de primeiro alocar a mem&oacute;ria + com o emalloc() ou estrdup(). Esta mem&oacute;ria n&atilde;o DEVE ser + liberada por voc&ecirc;, a menos que uma mesma fun&ccedil;&atilde;o sobreescreva + a fun&ccedil;&atilde;o original (esta pr&aacute;tica de programa&ccedil;&atilde;o + n&atilde;o &eacute; muito boa).</simpara> + + <simpara> + Para toda mem&oacute;ria tempor&aacute;ria/permanente que voc&ecirc; necessitar + usar em suas fun&ccedil;&otilde;es voc&ecirc; deve usar as tr&ecirc;s fun&ccedil;&otilde;es + emalloc(), estrdup(), e efree(). Elas comportam-se EXATAMENTE + como suas fun&ccedil;&otilde;es contrapartes. Para qualquer uso da emalloc() ou estrdup() + voc&ecirc; deve usar efree() em algum ponto ou outro, a menos que ela + precise ficar at&eacute; o fim do programa; se n&atilde;o, haver&aacute; um escape de mem&oacute;ria. + O significado de "as fun&ccedil;&otilde;es comportam-se exatamente como suas contrapartes" + &eacute;: se voc&ecirc; usa efree() em algo que n&atilde;o era emalloc()'ed ou estrdup()'ed + voc&ecirc; deve come&ccedil;ar uma falha na segmenta&ccedil;&atilde;o. Ent&atilde;o por favor tome cuidado e + libere toda sua mem&oacute;ria desperdi&ccedil;ada.</simpara> + + <simpara> + Se voc&ecirc; compilar com "-DDEBUG", o PHP ir&aacute; imprimir uma lsita + de toda mem&oacute;ria que foi alocada e usada com o emalloc() e estrdup() + mas nunca foi liberda com o efree() quando ele acabar de rodar um + script especificado.</simpara></sect2> <sect2 id="phpdevel-addfunc-symtab"> - <title>Setting Variables in the Symbol Table</title> + <title>Setando Vari&aacute;veis na Tabela de S&iacute;mbolos</title> <para> - A number of macros are available which make it easier to set a - variable in the symbol table: + Um n&uacute;mero de macros est&aacute; dispon&iacute;vel para tornar f&aacute;cil o trabalho + de setar uma vari&aacute;vel na tabela de s&iacute;mbolos: <itemizedlist> <listitem><simpara>SET_VAR_STRING(name,value)</simpara></listitem> @@ -211,29 +218,30 @@ <warning> <para> - Be careful with SET_VAR_STRING. The value part must be malloc'ed - manually because the memory management code will try to free this - pointer later. Do not pass statically allocated memory into a - SET_VAR_STRING. + Tenha cuidado com a SET_VAR_STRING. Parte do valor deve ser + malloc'ed manualmente porque o c&oacute;digo do gerenciador de mem&oacute;ria + ir&aacute; tentar lbierar este ponteiro mais tarde. N&atilde;o passe + mem&oacute;ria est&aacute;tica alocada na SET_VAR_STRING. </para> </warning> <simpara> - Symbol tables in PHP are implemented as hash tables. At any - given time, &amp;symbol_table is a pointer to the 'main' symbol - table, and active_symbol_table points to the currently active - symbol table (these may be identical like in startup, or - different, if you're inside a function).</simpara> + A tabela de s&iacute;mbolos no PHP &eacute; implementada como uma tabela de misutra. + A toda hora, &amp;symbol_table &eacute; apontado para o 'principal' + s&iacute;mbolo da tabela, e active_symbol_table aponta para o + s&iacute;mbolo corrente da tabela (isto pode ser identificado no + in&iacute;cio, ou diferente, se voc&ecirc; estiver dentro da fun&ccedil;&atilde;o).</simpara> <para> - The following examples use 'active_symbol_table'. You should - replace it with &amp;symbol_table if you specifically want to work - with the 'main' symbol table. Also, the same functions may be - applied to arrays, as explained below.</para> + O exemplo a seguir usa o 'active_symbol_table'. Voc&ecirc; + deve substituir isto por &amp;symbol_table se voc&ecirc; + quer especificamente trabalhar com a tabela de s&iacute;mbolos + 'principal'. Tamb&eacute;m, as mesmas fun&ccedil;&otilde;es se apliquem &agrave; + arrays, como explicado a seguir.</para> <para> <example> - <title>Checking whether $foo exists in a symbol table</title> + <title>Checando se $foo existe na tabela de s&iacute;mbolos</title> <programlisting role="c"> <![CDATA[ if (hash_exists(active_symbol_table,"foo",sizeof("foo"))) { exists... } @@ -243,7 +251,7 @@ </example> <example> - <title>Finding a variable's size in a symbol table</title> + <title>Procurando o tamanho de uma vari&aacute;vel em uma tabela de s&iacute;mbolos</title> <programlisting role="c"> <![CDATA[ hash_find(active_symbol_table,"foo",sizeof("foo"),&pvalue); @@ -252,24 +260,27 @@ </programlisting> </example> - Arrays in PHP are implemented using the same hashtables as - symbol tables. This means the two above functions can also be - used to check variables inside arrays.</para> + Os arrays no PHP s&atilde;o executadas usando as mesmas hashtables + que as tabelas de s&iacute;mbolos. Isto significa que as duas + fun&ccedil;&otilde;es abaixo tamb&eacute;m podem ser usadas para checar + vari&aacute;veis dentro de arrays.</para> <simpara> - If you want to define a new array in a symbol table, you should do - the following.</simpara> + Se voc&ecirc; quiser definir um novo array numa tabela de s&iacute;mbolos, + voc&ecirc; deve fazer o seguinte. + </simpara> <simpara> - First, you may want to check whether it exists and abort - appropriately, using hash_exists() or hash_find().</simpara> + Primeiro, voc&ecirc; talvez queria checar se j&aacute; n&atilde;o existe um array + e abort&aacute;-lo se houver, usando o hash_exists() ou hash_find(). + </simpara> <simpara> - Next, initialize the array:</simpara> + Ap&oacute;s, inicialize o array:</simpara> <para> <example> - <title>Initializing a new array</title> + <title>Inicializando um novo array</title> <programlisting role="c"> <![CDATA[ pval arr; @@ -280,15 +291,15 @@ </programlisting> </example> - This code declares a new array, named $foo, in the active symbol - table. This array is empty.</para> + Este c&oacute;digo declara um novo array, chamado $foo, na tabela + de s&iacute;mbolos ativa. Este array est&aacute; vazio.</para> <simpara> - Here's how to add new entries to it:</simpara> + Aqui est&aacute; o c&oacute;digo apra adicionar novas entrads &agrave; ele:</simpara> <para> <example> - <title>Adding entries to a new array</title> + <title>Adicionando novas entradas ao array</title> <programlisting role="c"> <![CDATA[ pval entry; @@ -309,21 +320,21 @@ ]]> </programlisting> </example> - - If you'd like to modify a value that you inserted to a hash, you - must first retrieve it from the hash. To prevent that overhead, - you can supply a pval ** to the hash add function, and it'll be - updated with the pval * address of the inserted element inside the - hash. If that value is &null; (like in all of the above examples) - - that parameter is ignored.</para> + + Se voc&ecirc; quiser modificar o valor que foi inserido ao hash, voc&ecirc; + deve primeiro peg&aacute;-lo do hash. Para previnir overhead, voc&ecirc; pode + suprir a pval ** da fun&ccedil;&atilde;o adicionar do hash, e isto ir&aacute; + atualizar com o endere&ccedil;o pval * do elemento inserido dentro + do hash. Se o valor for &null; (como em todos os exemplos abaixo) - + aquele par&acirc;metro &eacute; ignorado.</para> <simpara> - hash_next_index_insert() uses more or less the same logic as - "$foo[] = bar;" in PHP 2.0.</simpara> + hash_next_index_insert() usa mais ou menos a mesma l&oacute;gica que + "$foo[] = bar;" do PHP 2.0.</simpara> <simpara> - If you are building an array to return from a function, you can - initialize the array just like above by doing:</simpara> + Se voc&ecirc; est&aacute; construindo um array que retorna de uma fun&ccedil;&atilde;o, + voc&ecirc; pode inicializar o array como no exemplo abaixo:</simpara> <programlisting role="c"> <![CDATA[ @@ -332,7 +343,7 @@ </programlisting> <simpara> - ...and then adding values with the helper functions:</simpara> + ...e ent&atilde;o adicionar valores com as fun&ccedil;&otilde;es do helper:</simpara> <programlisting role="c"> <![CDATA[ @@ -343,8 +354,9 @@ </programlisting> <para> - Of course, if the adding isn't done right after the array - initialization, you'd probably have to look for the array first: + Claro, se a adi&ccedil;&atilde;o n&atilde;o terminou corretamente depois da + inicializa&ccedil;&atilde;o do array, voc&ecirc; provavelmente dever&aacute; + procurar pelo array primeiro: <programlisting role="c"> <![CDATA[ @@ -356,22 +368,22 @@ </programlisting></para> <simpara> - Note that hash_find receives a pointer to a pval pointer, and not - a pval pointer.</simpara> + Note que o hash_find recebe o ponteiro para um ponteiro pval, e + n&atilde;o um ponteiro pval.</simpara> <simpara> - Just about any hash function returns SUCCESS or FAILURE (except - for hash_exists(), which returns a boolean truth value).</simpara></sect2> + Assim como qualquer fun&ccedil;&atilde;o hash retorna SUCESSO ou FALHA (exceto + para o hash_exists(), que retorna um valor booleano verdadeiro).</simpara></sect2> <sect2 id="phpdevel-addfunc-retsimple"> - <title>Returning simple values</title> + <title>Retornando valores simples</title> <simpara> - A number of macros are available to make returning values from a - function easier.</simpara> + Um n&uacute;mero de macros est&atilde;o dispon&iacute;veis para fazer o retorno de + valores de uma fun&ccedil;&atilde;o ser muito mais f&aacute;cil.</simpara> <para> - The RETURN_* macros all set the return value and return from the - function: + A macro RETURN_* ajusta todos os valores de retorno e do retorno + da fun&ccedil;&atilde;o: <itemizedlist> <listitem><simpara>RETURN</simpara></listitem> <listitem><simpara>RETURN_FALSE</simpara></listitem> @@ -394,33 +406,34 @@ </itemizedlist></para> <simpara> - The string macros above will all estrdup() the passed 's' - argument, so you can safely free the argument after calling the - macro, or alternatively use statically allocated memory.</simpara> + As macros de string abaixo ser&atilde;o todas estrdup() passadas para + 's' argumento, ent&atilde;o voc&ecirc; pode seguramente liberar o argumento + ap&oacute;s chamar a macro, ou alternativamente usar uma mem&oacute;ria + est&aacute;tica alocada.</simpara> <simpara> - If your function returns boolean success/error responses, always - use RETURN_TRUE and RETURN_FALSE respectively.</simpara></sect2> + Se sua fun&ccedil;&atilde;o retornar respostas booleanas de sucesso/erro, + sempre use RETURN_TRUE e RETURN_FALSE respectivamente.</simpara></sect2> <sect2 id="phpdevel-addfunc-retcomplex"> - <title>Returning complex values</title> + <title>Retornando valores complexos</title> <simpara> - Your function can also return a complex data type such as an - object or an array.</simpara> + Sua fun&ccedil;&atilde;o pode tamb&eacute;m retornar um tipo de dado complexo assim + como um objeto ou um array.</simpara> <para> - Returning an object: + Retornando um objeto: <orderedlist numeration="arabic"> - <listitem><simpara>Call object_init(return_value).</simpara></listitem> - <listitem><para>Fill it up with values. The functions available - for this purpose are listed below.</para></listitem> - <listitem><para> Possibly, register functions for this object. - In order to obtain values from the object, the function would - have to fetch "this" from the active_symbol_table. Its type - should be IS_OBJECT, and it's basically a regular hash table - (i.e., you can use regular hash functions on .value.ht). The - actual registration of the function can be done using: + <listitem><simpara>Chamar o object_init(return_value).</simpara></listitem> + <listitem><para>Preencher isto com valores. A fun&ccedil;&atilde;o + dispon&iacute;vel para este prop&oacute;sito &eacute; listada a seguir.</para></listitem> + <listitem><para>Possivelmente, registrar a fun&ccedil;&atilde;o para este objeto. + A fim de obter os valores do objeto, a fun&ccedil;&atilde;o + teria que buscar "this" do active_symbol_table. Este + tipo dever&aacute; ser IS_OBJECT, e &eacute; basicamente uma tabela + hash regular (i.e., voc&ecirc; pode usar fun&ccedil;&otilde;es hash nos .value.ht). + O registrador atual da fun&ccedil;&atilde;o pode ser usado fazendo: <programlisting role="c"> <![CDATA[ add_method( return_value, function_name, function_ptr ); @@ -430,7 +443,7 @@ </orderedlist></para> <para> - The functions used to populate an object are: + As fun&ccedil;&otilde;es usadas para povoar um objeto: <itemizedlist> <listitem><simpara>add_property_long( return_value, property_name, l ) - Add a property named 'property_name', of @@ -444,16 +457,16 @@ </itemizedlist></para> <para> - Returning an array: + Retornando um array: <orderedlist numeration="arabic"> - <listitem><simpara>Call array_init(return_value).</simpara></listitem> - <listitem><simpara>Fill it up with values. The functions available - for this purpose are listed below.</simpara></listitem> + <listitem><simpara>Chamar array_init(return_value).</simpara></listitem> + <listitem><simpara>Preencher isto com valores. A fun&ccedil;&atilde;o dispon&iacute;vel + para este prop&oacute;sito &eacute; listada a seguir.</simpara></listitem> </orderedlist></para> <para> - The functions used to populate an array are: + As fun&ccedil;&otilde;es usadas para povoar um array s&atilde;o: <itemizedlist> <listitem><simpara>add_assoc_long(return_value,key,l) - add associative entry with key 'key' and long value 'l'</simpara></listitem> @@ -476,13 +489,13 @@ </itemizedlist></para></sect2> <sect2 id="phpdevel-addfunc-reslist"> - <title>Using the resource list</title> + <title>Usando a lista de recursos</title> <simpara> - PHP has a standard way of dealing with various types of - resources. This replaces all of the local linked lists in PHP 2.0.</simpara> + O PHP tem uma maneira padr&atilde;o de trator os v&aacute;rios tipos de + recursos. Isto substitui todos os local linked lists do PHP 2.0.</simpara> <para> - Available functions: + Fun&ccedil;&otilde;es dispon&iacute;veis: <itemizedlist> <listitem><simpara>php3_list_insert(ptr, type) - returns the 'id' @@ -494,16 +507,16 @@ updates 'type' to the resource's type</simpara></listitem> </itemizedlist> - Typically, these functions are used for SQL drivers but they can - be used for anything else; for instance, maintaining file - descriptors.</para> + Tipicamente, estas fun&ccedil;&otilde;es s&atilde;o usadas para drivers SQL mas + elas podem ser usadas para qualquer otura coisa; para instanciar, + manusear arquivos de descritores.</para> <simpara> - Typical list code would look like this:</simpara> + Um c&oacute;digo t&iacute;pico &eacute; listado a seguir:</simpara> <para> <example> - <title>Adding a new resource</title> + <title>Adicionando novos recursos</title> <programlisting role="c"> <![CDATA[ RESOURCE *resource; @@ -517,7 +530,7 @@ </example> <example> - <title>Using an existing resource</title> + <title>Usando um recurso existente</title> <programlisting role="c"> <![CDATA[ pval *resource_id; @@ -536,7 +549,7 @@ </example> <example> - <title>Deleting an existing resource</title> + <title>Deletando um recurso existente</title> <programlisting role="c"> <![CDATA[ pval *resource_id; @@ -548,21 +561,21 @@ ]]> </programlisting> </example> - - The resource types should be registered in php3_list.h, in enum - list_entry_type. In addition, one should add shutdown code for - any new resource type defined, in list.c's list_entry_destructor() - (even if you don't have anything to do on shutdown, you must add - an empty case).</para></sect2> + + O tipo de recurso deve ser registrado no php3_list.h, no enum + list_entry_type. Al&eacute;m disso, um deve adicionar c&oacute;digo para + qualquer novo tipo de recurso definido, em list.c's list_entry_destructor() + (mesmo se voc&ecirc; n&atilde;o tem nada para adicionar ao shutdown, voc&ecirc; + deve adicionar um caso em branco).</para></sect2> <sect2 id="phpdevel-addfunc-prestable"> - <title>Using the persistent resource table</title> + <title>Usando o recurso persistente da tabela</title> <para> - PHP has a standard way of storing persistent resources (i.e., - resources that are kept in between hits). The first module to use - this feature was the MySQL module, and mSQL followed it, so one - can get the general impression of how a persistent resource should - be used by reading mysql.c. The functions you should look at are: + O PHP tem uma maneira padr&atilde;o de armazenar recursos persistentes (i.e., + recursos que s&atilde;o mantidos dentre os hits). O primeiro m&oacute;dulo &agrave; usar + esta caracter&iacute;stica foi o m&oacute;dulo MySQL, e mSQL seguindo-os, ent&atilde;o + um pode pegar uma impress&atilde;o geral de como um recurso persistente + deve ser usado lendo mysql.c. As fun&ccedil;&otilde;es devem se parecem com as abaixo: <simplelist> <member>php3_mysql_do_connect</member> @@ -571,33 +584,31 @@ </simplelist></para> <para> - The general idea of persistence modules is this: + A id&eacute;ia geral dos m&oacute;dulos persistentes &eacute; esta: <orderedlist numeration="arabic"> - <listitem><simpara>Code all of your module to work with the - regular resource list mentioned in section (9).</simpara></listitem> - <listitem><simpara>Code extra connect functions that check if the - resource already exists in the persistent resource list. If it - does, register it as in the regular resource list as a pointer to - the persistent resource list (because of 1., the rest of the code - should work immediately). If it doesn't, then create it, add it - to the persistent resource list AND add a pointer to it from the - regular resource list, so all of the code would work since it's - in the regular resource list, but on the next connect, the - resource would be found in the persistent resource list and be - used without having to recreate it. You should register these - resources with a different type (e.g. LE_MYSQL_LINK for - non-persistent link and LE_MYSQL_PLINK for a persistent link).</simpara></listitem> + <listitem><simpara>Codifique todos os seus m&oacute;dulos para trabalhar + com um recurso regular mecionados na se&ccedil;&atilde;o (9).</simpara></listitem> + <listitem><simpara>Codifique fun&ccedil;&otilde;es extras de conex&atilde;o para checar + se o recurso j&aacute; existe na lista de recursos persistentes. Se j&aacute; + existir, registre ela na lista de recursos regular como um ponteiro + para a lista de recursos persistentes (porque o 1., o resto do c&oacute;digo + dever&aacute; funcionar imediatamente). Se ela n&atilde;o existe, ent&atilde;o crie ela, adicione-a + a lista de recursos persistentes E adicione um ponteiro para ela vindo da + lista de recursos regular, mas na pr&oacute;xima conex&atilde;o, o recurso + ser&aacute; encontrado na lsita de recursos persitentes e ser&aacute; usado + sem ter que recri&aacute;-lo. Voc&ecirc; deve registrar estes recursos + com um tipo diferente (e.g. LE_MYSQL_LINK para link + n&atilde;o-persistente e LE_MYSQL_PLINK para um link persistente).</simpara></listitem> </orderedlist></para> <simpara> - If you read mysql.c, you'll notice that except for the more - complex connect function, nothing in the rest of the module has to - be changed.</simpara> + Se voc&ecirc; ler o mysql.c, voc&ecirc; ir&aacute; notar que exceto pela fun&ccedil;&atilde;o + complexa de conex&atilde;o, nada no resto do m&oacute;dulo tem que ser mudado.</simpara> <simpara> - The very same interface exists for the regular resource list and - the persistent resource list, only 'list' is replaced with - 'plist':</simpara> + A mesma rela&ccedil;&atilde;o existe para a lista de recursos regular e + para a lista de recursos persistentes, somente a 'list' &eacute; + substitu&iacute;da com 'plist':</simpara> <itemizedlist> <listitem><simpara>php3_plist_insert(ptr, type) - returns the 'id' @@ -610,284 +621,295 @@ </itemizedlist> <simpara> - However, it's more than likely that these functions would prove to - be useless for you when trying to implement a persistent module. - Typically, one would want to use the fact that the persistent - resource list is really a hash table. For instance, in the - MySQL/mSQL modules, when there's a pconnect() call (persistent - connect), the function builds a string out of the host/user/passwd - that were passed to the function, and hashes the SQL link with - this string as a key. The next time someone calls a pconnect() - with the same host/user/passwd, the same key would be generated, - and the function would find the SQL link in the persistent list.</simpara> - - <simpara> - Until further documented, you should look at mysql.c or msql.c to - see how one should use the plist's hash table abilities.</simpara> - - <simpara> - One important thing to note: resources going into the persistent - resource list must *NOT* be allocated with PHP's memory manager, - i.e., they should NOT be created with emalloc(), estrdup(), etc. - Rather, one should use the regular malloc(), strdup(), etc. The - reason for this is simple - at the end of the request (end of the - hit), every memory chunk that was allocated using PHP's memory - manager is deleted. Since the persistent list isn't supposed to - be erased at the end of a request, one mustn't use PHP's memory - manager for allocating resources that go to it.</simpara> - - <simpara> - When you register a resource that's going to be in the persistent - list, you should add destructors to it both in the non-persistent - list and in the persistent list. The destructor in the - non-persistent list destructor shouldn't do anything. The one in - the persistent list destructor should properly free any resources - obtained by that type (e.g. memory, SQL links, etc). Just like - with the non-persistent resources, you *MUST* add destructors for - every resource, even it requires no destruction and the - destructor would be empty. Remember, since emalloc() and friends - aren't to be used in conjunction with the persistent list, you - mustn't use efree() here either.</simpara></sect2> + Entretanto, &eacute; mais prov&aacute;vel que estas fun&ccedil;&otilde;es provariam ser + in&uacute;tils a n&atilde;o quando voc&ecirc; tenta implementar um m&oacute;dulo persistente. + Tipicamente, um seria usada de fato para a lista de recursos + persistentes que realmente seria uma tabela hash. Para instanciar, + nos m&oacute;dulos de conex&atilde;o MySQL/mSQL, quando existe uma chamada + pconnect() (conex&atilde;o persistente), a fun&ccedil;&atilde;o constr&oacute;i uma string fora + do host/usr/passwd que s&atilde;o passadas para a fun&ccedil;&atilde;o, e mistura o link + SQL com esta string como uma chave. Na pr&oacute;xima vez que algu&eacute;m + chamar a pconnect() com os mesmos host/user/passwd, a mesma chave + dever&aacute; ser gerada, e a fun&ccedil;&atilde;o encontraria o link SQL na + lista persistente.</simpara> + + <simpara> + At&eacute; que seja feita documenta&ccedil;&atilde;o adicional, voc&ecirc; deve olhar no + mysql.c ou msql.c para ver como deve usar as habilidades da + plist's tabela de hash.</simpara> + + <simpara> + Uma coisa importante a notar: recursos que v&atilde;o para para a lista + de recursos persistentes *N&Atilde;O" devem ser alocados no gerenciador + de mem&oacute;ria do PHP, i.e., N&Atilde;O devem ser criados com emalloc(), strdup(), etc. + O motivo para isto &eacute; simples - ao fim da requisi&ccedil;&atilde;o (fim do hit), + cada peda&ccedil;o de mem&oacute;ria que foi alocada usando o gerenciador + de mem&oacute;ria do PHP &eacute; deletado. Desde que a lista persistente + n&atilde;o &eacute; supostamente para ser deletada ao fim da requisi&ccedil;&atilde;o, + n&atilde;o se deve usar o gerenciador de mem&oacute;ria do PHP + para alocar recursos que v&atilde;o para ela.</simpara> + + <simpara> + Quando voc&ecirc; registra um recurso que vai ficar na lista persistente, + voc&ecirc; deve adicionar desconstrutores em ambas as listas persistente + e n&atilde;o-persistente. O desconstrutor na lista n&atilde;o-persistente + n&atilde;o deve fazer nada. J&aacute; o que est&aacute; na lista persistente + deve liberar corretamente qualquer recurso obtido por este + tipo (e.g. mem&oacute;ria, SQL links, etc). Assim como os recursos da lista + n&atilde;o-persistente, voc&ecirc; *DEVE* adicionar desconstrutores para + qualquer recurso, mesmo os que n&atilde;o requerem desconstrutores + e este desconstrutor ficaria vazio. Lembre-se, desde que + emalloc() e seus amigos n&atilde;o est&atilde;o sendo usados em conjunto + com a lista persistente, voc&ecirc; n&atilde;o deve usar o efree().</simpara></sect2> <sect2 id="phpdevel-addfunc-addcfg"> - <title>Adding runtime configuration directives</title> + <title>Adicionar diretivas de configura&ccedil;&atilde;o runtime</title> <para> - Many of the features of PHP can be configured at runtime. These - configuration directives can appear in either the designated - php3.ini file, or in the case of the Apache module version in the - Apache .conf files. The advantage of having them in the Apache - .conf files is that they can be configured on a per-directory - basis. This means that one directory may have a certain - safemodeexecdir for example, while another directory may have - another. This configuration granularity is especially handy when - a server supports multiple virtual hosts.</para> + Muitas caracter&iacute;sticas do PHP podem ser configuradas em modo runtime. + Estas diretivas de configura&ccedil;&otilde;es podem aparecer no arquivo de + configura&ccedil;&atilde;o php3.ini, ou no caso na vers&atilde;o do m&oacute;dul para o Apache + nos arquivos .conf do Apache. A vantagem de t&ecirc;-las nos arquivos + .conf do Apache &eacute; que elas podem ser configuradas em apenas + um diret&oacute;rio. Isto significa que um diret&oacute;rio pode ter um certo + safemodeexecdir por exemplo, enquanto em outro diret&oacute;rio + pode ter um outro tipo de safemodeexecdir. Estas configura&ccedil;&otilde;es + s&atilde;o especiamente acess&iacute;veis quando um servidor suporta + m&uacute;ltiplos hosts virtuais.</para> <para> - The steps required to add a new directive: + Os requisitos para adicionar uma diretiva: <orderedlist> - <listitem><simpara>Add directive to php3_ini_structure struct in mod_php3.h.</simpara></listitem> + <listitem><simpara>Adicione a diretiva php3_ini_structure struct em mod_php3.h.</simpara></listitem> - <listitem><simpara>In main.c, edit the php3_module_startup - function and add the appropriate cfg_get_string() or - cfg_get_long() call.</simpara></listitem> - - <listitem><simpara>Add the directive, restrictions and a comment - to the php3_commands structure in mod_php3.c. Note the - restrictions part. RSRC_CONF are directives that can only be - present in the actual Apache .conf files. Any OR_OPTIONS - directives can be present anywhere, include normal .htaccess - files.</simpara></listitem> - - <listitem><simpara>In either php3take1handler() or - php3flaghandler() add the appropriate entry for your directive.</simpara></listitem> - - <listitem><simpara>In the configuration section of the - _php3_info() function in functions/info.c you need to add your - new directive.</simpara></listitem> - - <listitem><simpara>And last, you of course have to use your new - directive somewhere. It will be addressable as - php3_ini.directive.</simpara></listitem> + <listitem><simpara>No main.c, edite a fun&ccedil;&atilde;o php3_module_startup + e adicione a chamada apropriada cfg_get_string() ou + cfg_get_long().</simpara></listitem> + + <listitem><simpara>Adicione a diretiva, restri&ccedil;&otilde;es e coment&aacute;rios + &agrave; estrutura de php3_commands em mod_php3.c. Anote as partes + restritras. RSRC_CONF s&atilde;o diretivas que somente est&atilde;o presentes + nos arquivos .conf do Apache. Qualquer + diretiva OR_OPTIONS pode estar presente em qualquer lugar, + incluindo os arquivos .htaccess.</simpara></listitem> + + <listitem><simpara>Em php3takelhandler() ou php3flaghandler() + adicione a entrada apropriada para sua diretiva.</simpara></listitem> + + <listitem><simpara>Na se&ccedil;&atilde;o de configura&ccedil;&atilde;o da fun&ccedil;&atilde;o + _php3_info() em functions/info.c voc&ecirc; precisa adicionar + sua nova diretiva.</simpara></listitem> + + <listitem><simpara>E por &uacute;ltimo, voc&ecirc; naturalmente tem que + usar sua nova diretiva em algum lugar. Ela ser&aacute; + endere&ccedil;ada como php3_ini.directive.</simpara></listitem> </orderedlist></para></sect2></sect1> <sect1 id="calling-user-functions"> - <title>Calling User Functions</title> + <title>Chamando Fun&ccedil;&otilde;es do Usu&aacute;rio</title> <simpara> - To call user functions from an internal function, you should use - the <function>call_user_function</function> function. + Para chamar fun&ccedil;&otilde;es do usu&aacute;rio de uma fun&ccedil;&atilde;o interna, voc&ecirc; + deve usar a fun&ccedil;&atilde;o <function>call_user_function</function>. </simpara> <simpara> - <function>call_user_function</function> returns SUCCESS on success, - and FAILURE in case the function cannot be found. You should check - that return value! If it returns SUCCESS, you are responsible for - destroying the retval pval yourself (or return it as the return value - of your function). If it returns FAILURE, the value of retval is - undefined, and you mustn't touch it. + <function>call_user_function</function> retorna SUCESSO no sucesso, + e FALHA no caso de a fun&ccedil;&atilde;o n&atilde;o ter sido encontrada. + Voc&ecirc; deve checar este valor de retorno! Se ela retornar SUCESSO, + voc&ecirc; &eacute; respons&aacute;vel por destruir a retval pval por voc&ecirc; mesmo + (ou retornar ela como um valor de retorno da sua fun&ccedil;&atilde;o). + Se ela retornar FALHA, o valor da retval &eacute; indefinido, + e voc&ecirc; n&atilde;o deve mexe nisto. </simpara> <simpara> - All internal functions that call user functions - <emphasis>must</emphasis> be reentrant. Among other things, this - means they must not use globals or static variables. + Todas as fun&ccedil;&otilde;es internas que chama fun&ccedil;&otilde;es + de usu&aacute;rio <emphasis>devem</emphasis> ser reentrantes. + Entre outras coisas, isto significa que ela n&atilde;o deve + usar vari&aacute;veis globais ou est&aacute;ticas. </simpara> <simpara> - <function>call_user_function</function> takes six arguments: + <function>call_user_function</function> usa seis argumentos: </simpara> <sect2 id="calling-user-functions.function-table"> <title>HashTable *function_table</title> <simpara> - This is the hash table in which the function is to be looked up. + Esta &eacute; a tabela hash onde a fun&ccedil;&atilde;o deve ser procurada. </simpara></sect2> <sect2 id="calling-user-functions.object"> <title>pval *object</title> <simpara> - This is a pointer to an object on which the function is invoked. - This should be &null; if a global function is called. If it's not - &null; (i.e. it points to an object), the function_table argument is - ignored, and instead taken from the object's hash. The object *may* - be modified by the function that is invoked on it (that function - will have access to it via $this). If for some reason you don't - want that to happen, send a copy of the object instead. + Este &eacute; o ponteiro para um objeto em que a fun&ccedil;&atilde;o &eacute; invocada. + Ele dever &null; se a fun&ccedil;&atilde;o global &eacute; chamada. E se ele + n&atilde;o &eacute; &null; (i.e. este ponteio &eacute; um objeto), o argumento + function_table &eacute; ignorado, ao inv&eacute;s de pegar o hash do objeto. + O objeto *talvez* seja modificado pela fun&ccedil;&atilde;o que &eacute; invocada + nele (esta fun&ccedil;&atilde;o talvez tenha acesso a ele via $this). + Se por alguma raz&atilde;o voc&ecirc; n&atilde;o quer que isto aconte&ccedil;a, + envie uma c&oacute;pia do objeto ao inv&eacute;s dele. </simpara></sect2> <sect2 id="calling-user-functions.function-name"> <title>pval *function_name</title> <simpara> - The name of the function to call. Must be a pval of type - IS_STRING with function_name.str.val and function_name.str.len - set to the appropriate values. The function_name is modified by - call_user_function() - it's converted to lowercase. If you need to - preserve the case, send a copy of the function name instead. + O nome da fun&ccedil;&atilde;o &agrave; ser chamada. Deve ser um pval do tipo + IS_STRING com function_name.str.val e function_name.str.len + enviando os valores apropriados. A function_name &eacute; modificada + por call_user_function() - que &eacute; convertido para letra min&uacute;scula. + Se voc&ecirc; precisa preservar caso, envie uma c&oacute;pia do + nome da fun&ccedil;&atilde;o ao inv&eacute;s dela. </simpara></sect2> <sect2 id="calling-user-functions.retval"> <title>pval *retval</title> <simpara> - A pointer to a pval structure, into which the return value of - the invoked function is saved. The structure must be previously - allocated - <function>call_user_function</function> does NOT allocate - it by itself. + Um ponteiro para uma estrutura do pval, onde o valor + retornada do a fun&ccedil;&atilde;o invocada &eacute; salvo. A estrutura deve + previamente alocada - <function>call_user_function</function> + N&Atilde;O aloque por voc&ecirc; mesmo. </simpara></sect2> <sect2 id="calling-user-functions.param-count"> <title>int param_count</title> <simpara> - The number of parameters being passed to the function. + O n&uacute;mero de par&acirc;metros passados &agrave; fun&ccedil;&atilde;o. </simpara></sect2> <sect2 id="calling-user-functions.params"> <title>pval *params[]</title> <simpara> - An array of pointers to values that will be passed as arguments to the - function, the first argument being in offset 0, the second in offset - 1, etc. The array is an array of pointers to pval's; The pointers - are sent as-is to the function, which means if the function modifies - its arguments, the original values are changed (passing by reference). - If you don't want that behavior, pass a copy instead. + Um array de ponteiros para valores que v&atilde;o ser passados + como argumentos para a fun&ccedil;&atilde;o, o primeiro argumento come&ccedil;a no + offset 0, o segundo no offset 1, etc. O array &eacute; um array + de ponteiros para pval's; Os ponteiros s&atilde;o + enviados como-s&atilde;o para a fun&ccedil;&atilde;o, isto significa que se a fun&ccedil;&atilde;o + &eacute; modificada por seus argumentos, os valores originais s&atilde;o + alterados (passando por refer&ecirc;ncia). + Se voc&ecirc; n&atilde;o quer este comportamento, passe uma c&oacute;pia ao + inv&eacute;s do original. </simpara></sect2></sect1> <sect1 id="phpdevel-errors"> - <title>Reporting Errors</title> + <title>Relatando erros</title> <simpara> - To report errors from an internal function, you should call the - <function>php3_error</function> function. This takes at least two - parameters -- the first is the level of the error, the second is - the format string for the error message (as in a standard - <function>printf</function> call), and any following arguments - are the parameters for the format string. The error levels are: + Para relatar erros de uma fun&ccedil;&atilde;o interna, voc&ecirc; deve chamar a + fun&ccedil;&atilde;o <function>php3_error</function>. Ela pega ao menos + dois par&acirc;metros -- o primeiro &eacute; o n&iacute;vel do erro, o segundo + &eacute; a string formatada para a mensagem de erro (como em uma + chamada padr&atilde;o <function>printf</function>), e os argumentos + seguintes s&atilde;o os par&acirc;metros para a string formatada. Os n&iacute;veis + de erro s&atilde;o: </simpara> <sect2 id="internal.e-notice"> <title>E_NOTICE</title> <simpara> - Notices are not printed by default, and indicate that the script - encountered something that could indicate an error, but could also - happen in the normal course of running a script. For example, - trying to access the value of a variable which has not been set, - or calling <function>stat</function> on a file that doesn't exist. + Avisos n&atilde;o s&atilde;o mostrados por padr&atilde;o, e indicam que o script + encontrou algo que poderia indicar um erro, mas que pode + tamb&eacute;m ter acontecido na execu&ccedil;&atilde;o do script. Por exemplo, + tentando acessar um valor de uma vari&aacute;vel que n&atilde;o foi setada, + ou chamando <function>stat</function> em um arquivo que n&atilde;o existe. </simpara> </sect2> <sect2 id="internal.e-warning"> <title>E_WARNING</title> <simpara> - Warnings are printed by default, but do not interrupt script - execution. These indicate a problem that should have been trapped - by the script before the call was made. For example, calling - <function>ereg</function> with an invalid regular expression. + Os avisos s&atilde;o mostrados por padr&atilde;o, mas n&atilde;o interrompem a + execu&ccedil;&atilde;o do script. Eles indicam um problema que deve ter + acontecido antes do script ser chamado. Por exemplo, + chamando <function>ereg</function> com uma express&atilde;o regular inv&aacute;lida. </simpara> </sect2> <sect2 id="internal.e-error"> <title>E_ERROR</title> <simpara> - Errors are also printed by default, and execution of the script is - halted after the function returns. These indicate errors that can - not be recovered from, such as a memory allocation problem. + Os erros tamb&eacute;m s&atilde;o mostrados por padr&atilde;o, e a execu&ccedil;&atilde;o do script &eacute; + interrompida ap&oacute;s a fun&ccedil;&atilde;o retornar. Ele indica erros que podem + n&atilde;o ser recuperados, como um problema de aloca&ccedil;&atilde;o de mem&oacute;ria. </simpara> </sect2> <sect2 id="internal.e-parse"> <title>E_PARSE</title> <simpara> - Parse errors should only be generated by the parser. The code is - listed here only for the sake of completeness. + Erros do Parse deveriam unicamente ser gerados somente pelo parser. O c&oacute;digo &eacute; + listado aqui somente para a causa de integridade. </simpara> </sect2> <sect2 id="internal.e-core-error"> <title>E_CORE_ERROR</title> <simpara> - This is like an E_ERROR, except it is generated by the core - of PHP. Functions should not generate this type of error. + Este &eacute; como um E_ERROR, exceto que ele &eacute; gerado pelo n&uacute;cleo + do PHP. Fun&ccedil;&otilde;es n&atilde;o devem gerar este tipo de erro. </simpara> </sect2> <sect2 id="internal.e-core-warning"> <title>E_CORE_WARNING</title> <simpara> - This is like an E_WARNING, except it is generated by the core - of PHP. Functions should not generate this type of error. + Este &eacute; como um E_WARNING, exceto que ele &eacute; gerado pelo n&uacute;cleo + do PHP. Fun&ccedil;&otilde;es n&atilde;o devem gerar este tipo de erro. </simpara> </sect2> <sect2 id="internal.e-compile-error"> <title>E_COMPILE_ERROR</title> <simpara> - This is like an E_ERROR, except it is generated by the Zend Scripting - Engine. Functions should not generate this type of error. + Este &eacute; como um E_ERROR, exceto que ele &eacute; gerado pelo Zend Scripting + Engine. Fun&ccedil;&otilde;es n&atilde;o devem gerar este tipo de erro. </simpara> </sect2> <sect2 id="internal.e-compile-warning"> <title>E_COMPILE_WARNING</title> <simpara> - This is like an E_WARNING, except it is generated by the Zend Scripting - Engine. Functions should not generate this type of error. + Este &eacute; como um E_WARNING, exceto que ele &eacute; gerado pelo Zend Scripting + Engine. Fun&ccedil;&otilde;es n&atilde;o devem gerar este tipo de erro. </simpara> </sect2> <sect2 id="internal.e-user-error"> <title>E_USER_ERROR</title> <simpara> - This is like an E_ERROR, except it is generated in PHP code by using - the PHP function <function>trigger_error</function>. Functions should - not generate this type of error. + Este &eacute; como um E_ERROR, exceto que ele &eacute; gerado no c&oacute;digo PHP + usando a fun&ccedil;&atilde;o PHP <function>trigger_error</function>. + Fun&ccedil;&otilde;es n&atilde;o devem gerar este tipo de erro. </simpara> </sect2> <sect2 id="internal.e-user-warning"> <title>E_USER_WARNING</title> <simpara> - This is like an E_WARNING, except it is generated by using the PHP - function <function>trigger_error</function>. Functions should not - generate this type of error. + Este &eacute; como um E_WARNING, exceto que ele &eacute; gerado no c&oacute;digo PHP + usando a fun&ccedil;&atilde;o PHP <function>trigger_error</function>. + Fun&ccedil;&otilde;es n&atilde;o devem gerar este tipo de erro. </simpara> </sect2> <sect2 id="internal.e-user-notice"> <title>E_USER_NOTICE</title> <simpara> - This is like an E_NOTICE, except it is generated by using the PHP - function <function>trigger_error</function>. Functions should not - generate this type of error. + Este &eacute; como um E_NOTICE, exceto que ele &eacute; gerado no c&oacute;digo PHP + usando a fun&ccedil;&atilde;o PHP <function>trigger_error</function>. + Fun&ccedil;&otilde;es n&atilde;o devem gerar este tipo de erro. </simpara> </sect2> <sect2 id="internal.e-all"> <title>E_ALL</title> <simpara> - All of the above. Using this error_reporting level will show - all error types. + Todos acima. Usando este n&iacute;vel de error_reporting voc&ecirc; + ver&aacute; todos os tipos de erros. </simpara> </sect2> Index: phpdoc/en/appendices/migration4.xml diff -u phpdoc/en/appendices/migration4.xml:1.25 phpdoc/en/appendices/migration4.xml:1.26 --- phpdoc/en/appendices/migration4.xml:1.25 Tue Oct 8 07:11:46 2002 +++ phpdoc/en/appendices/migration4.xml Wed Nov 20 07:19:11 2002 @@ -1,43 +1,43 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.25 $ --> +<!-- $Revision: 1.26 $ --> <appendix id="migration4"> - <title>Migrating from PHP 3 to PHP 4</title> + <title>Migrando do PHP 3 para o PHP 4</title> <section id='migration4.changes'> - <title>What has changed in PHP 4</title> + <title>O que mudou no PHP 4</title> <para> - PHP 4 and the integrated Zend engine have greatly improved PHP's - performance and capabilities, but great care has been taken to - break as little existing code as possible. So migrating your code - from PHP 3 to 4 should be much easier than migrating from - PHP/FI 2 to PHP 3. A lot of existing PHP 3 code should be - ready to run without changes, but you should still know about the - few differences and take care to test your code before switching - versions in production environments. The following should give you - some hints about what to look for. + O PHP 4 e a integra&ccedil;&atilde;o com o engine Zend melhoraram incrivelmente a + performance e potencialidades do PHP, mas foi tomado o cuidado + de deixar o c&oacute;digo existente o m&aacute;ximo poss&iacute;vel. Sendo assim, migrar seu + c&oacute;digo do PHP 3 para PHP 4 &eacute; muito mais f&aacute;cil do que migrar do PHP/FI 2 para PHP 3. + Muitos c&oacute;digos existentes do PHP 3 podem rodar sem altera&ccedil;&otilde;es, mas voc&ecirc; dever&aacute; + ficar atento as diferenta&ccedil;as e ter o cuidado de testar seu c&oacute;digo antes de trocar as + vers&otilde;es nos sistemas de produ&ccedil;&otilde;es. O material abaixo dever&aacute; dar &agrave; + voc&ecirc; algumas instru&ccedil;&otilde;es sobre o que procurar. </para> </section> <section id="migration4.php4.with.php3"> - <title>Running PHP 3 and PHP 4 concurrently</title> + <title>Rodando PHP 3 e PHP 4 simultaneamente</title> <simpara> - Recent operating systems provide the ability to perform - versioning and scoping. This features make it possible to let - PHP 3 and PHP 4 run as concurrent modules in one Apache server. + Os sistemas operacionais atuais fornecem a habilidade de de + executar "versioning" e "scoping". Estas caracter&iacute;sticas + tornam poss&iacute;vel deixar-mos o PHP 3 e PHP 4 rodando simultaneamente + como m&oacute;dulos em um s&oacute; servidor Apache. </simpara> <simpara> - This feature is known to work on the following platforms: + Esta op&ccedil;&atilde;o &eacute; suportada nas seguintes plataformas: </simpara> <itemizedlist> - <listitem><simpara>Linux with recent binutils (binutils 2.9.1.0.25 tested) </simpara></listitem> - <listitem><simpara>Solaris 2.5 or better</simpara></listitem> - <listitem><simpara>FreeBSD (3.2, 4.0 tested)</simpara></listitem> + <listitem><simpara>Linux com os recentes binutils (binutils 2.9.1.0.25 testado) </simpara></listitem> + <listitem><simpara>Solaris 2.5 ou superior</simpara></listitem> + <listitem><simpara>FreeBSD (3.2, 4.0 testado)</simpara></listitem> </itemizedlist> <para> - To enable it, configure PHP3 and PHP4 to use APXS - (--with-apxs) and the necessary link extensions - (--enable-versioning). Otherwise, all standard installations - instructions apply. For example: + Para habilitar isto, configure seu PHP 3 e PHP 4 usando o APXS + (--with-apxs) e linkar as extens&otilde;es necess&aacute;rias (--enable-versioning). + Por outro lado, isto tamb&eacute;m se aplica para todas as instala&ccedil;&otilde;es padr&otilde;es. + Por exemplo: <informalexample> <programlisting role="configure"> <![CDATA[ @@ -53,15 +53,15 @@ </section> <section id="migration4.configuration"> - <title>Migrating Configuration Files</title> + <title>Migrando os arquivos de configura&ccedil;&atilde;o</title> <para> - The global configuration file, <filename>php3.ini</filename>, - has changed its name to &php.ini;. + O arquivo de configura&ccedil;&atilde;o global, <filename>php3.ini</filename>, + foi alterado para ete nome &php.ini;. </para> <para> - For the Apache configuration file, there are slightly more - changes. The MIME types recognized by the PHP module have - changed. + Para o arquivo de configura&ccedil;&atilde;o do Apache, h&aacute; algumas pequenas + mudan&ccedil;as. Os tipos de MIME reconhecidos pelo m&oacute;dulo do PHP foram + alterados. <informalexample> <programlisting role="apache"> <![CDATA[ @@ -72,9 +72,9 @@ </informalexample> </para> <para> - You can make your configuration files work with both versions - of PHP (depending on which one is currently compiled into the - server), using the following syntax: + Você pode fazer seu arquivo de configuração trabalhar com ambas as + versões do PHP (dependendo de qual compilação está no servidor), + usando a seguinte sintaxe: <informalexample> <programlisting> <![CDATA[ @@ -88,11 +88,11 @@ </informalexample> </para> <simpara> - In addition, the PHP directive names for Apache have changed. + Al&eacute;m disso, os nomes das diretiva do PHP para o Apache foram alteradas. </simpara> <para> - Starting with PHP 4.0, there are only four Apache directives - that relate to PHP: + Come&ccedil;ando com o PHP 4.0, h&aacute; quatro diretivas para o Apache relacionadas + ao PHP: <informalexample> <programlisting role="apache"> <![CDATA[ @@ -105,17 +105,23 @@ </informalexample> </para> <simpara> - There are two differences between the Admin values and the non admin values: + H&aacute; duas diferen&ccedil;as entre os valores do Admin e do n&atilde;o admin: </simpara> <itemizedlist> - <listitem><simpara>Admin values (or flags) can only appear in the server-wide apache configuration files (e.g., httpd.conf).</simpara></listitem> - <listitem><simpara>Standard values (or flags) cannot control certain PHP directives, for example - safe mode (if you could override safe mode settings in .htaccess files, it would defeat safe-mode's purpose). In contrast, Admin values can modify the value of any PHP directive.</simpara></listitem> + <listitem><simpara>Os valores Admin (ou os flags) s&oacute; aparecem no server-wide dos arquivos de configura&ccedil;&atilde;o + do apache (e.g., httpd.conf).</simpara></listitem> + <listitem><simpara>Os valores padr&otilde;es (ou os flags) n&atilde;o podem controlar determinadas diretivas do PHP, + por exemplo - safe mode (se voc&ecirc; pude-se cancelar as configura&ccedil;&otilde;es do modo seguro em arquivos .htacces, + isto desativaria o modo-seguro). Em contraste, os valores Admin podem modificar qualquer diretiva do PHP.</simpara></listitem>. </itemizedlist> <simpara> - To make the transition process easier, PHP 4 is bundled with scripts that automatically convert your Apache configuration and .htaccess files to work with both PHP 3 and PHP 4. These scripts do NOT convert the mime type lines! You have to convert these yourself. + Para tornar o processo de transi&ccedil;&atilde;o mais f&aacute;cil, o PHP 4 vem com scripts que convertem automaticamente + suas configura&ccedil;&otilde;es do Apache e arquivos .htacces para trabalharem com ambos PHP 3 e PHP 4. Estes scripts + N&Atilde;O convertem as linhas do tipo MIME! Voc&ecirc; ter&aacute; que converter manualmente. </simpara> <para> - To convert your Apache configuration files, run the apconf-conv.sh script (available in the scripts/apache/ directory). For example: + Para converter seus arquivos de configura&ccedil;&atilde;o do Apache, rode o script apconf-conv.sh (distpon&iacute;vel no + diret&oacute;rio /scripts/apache). Exemplo: <informalexample> <programlisting role="shell"> <![CDATA[ @@ -125,10 +131,11 @@ </informalexample> </para> <simpara> - Your original configuration file will be saved in httpd.conf.orig. + Seu arquivo de configura&ccedil;&atilde;o original ser&aacute; salve como httpd.conf.orig. </simpara> <para> - To convert your .htaccess files, run the aphtaccess-conv.sh script (available in the scripts/apache/ directory as well): + Para converter seus arquivos .htaccess, rode o script aphtaccess-conv.sh (dispon&iacute;vel no + diret&oacute;rio scripts/apache), exemplo: <informalexample> <programlisting role="shell"> <![CDATA[ @@ -138,315 +145,316 @@ </informalexample> </para> <simpara> - Likewise, your old .htaccess files will be saved with an .orig prefix. + Como j&aacute; foi dito, seus antigos arquivos .htacces ser&atilde;o salvos com o prefixo .orig. </simpara> <simpara> - The conversion scripts require awk to be installed. + A convers&atilde;o dos scripts requer que o awk esteja instalado. </simpara> </section> <section id='migration4.parser'> - <title>Parser behavior</title> + <title>Comportamento da Análise</title> <para> - Parsing and execution are now two completely separated steps, no - execution of a files code will happen until the complete file and - everything it requires has completely and successfully been - parsed. + A execução e a análise são agora duas etapas completamente separadas, + nenhuma execução de código de arquivo será acontecerá até que tudo seja + completado e analisado completamente. </para> <para> - One of the new requirements introduced with this split is that - required and included files now have to be syntactically - complete. You can no longer spread the different controlling parts - of a control structure across file boundaries. That is you cannot - start a <literal>for</literal> or <literal>while</literal> loop, - an <literal>if</literal> statement or a <literal>switch</literal> - block in one file and have the end of loop, - <literal>else</literal>, <literal>endif</literal>, - <literal>case</literal> or <literal>break</literal> statements in - a different file. + Uma das novas exig&ecirc;ncias introduzidas com este split &eacute; que + arquivos requeridos e inclu&iacute;dos agora tem que estar sintaticamente + completos. Voc&ecirc; n&atilde;o pode mais espalhar os em diferentes partes os + controles de estrutura ou espalahar os controles atrav&eacute;s de arquivos. + Voc&ecirc; n&atilde;o pode come&ccedil;ar um la&ccedil;o <literal>for</literal> ou <literal>while</literal>, + um bloco de instru&ccedil;&otilde;es <literal>if</literal> ou <literal>switch</literal> come&ccedil;ando + em um arquivo e terminar o loop, <literal>else</literal>, <literal>endif</literal>, + <literal>case</literal> ou <literal>break</literal> em um arquivo diferente. </para> <para> - It still perfectly legal to include additional code within loops - or other control structures, only the controlling keywords and - corresponding curly braces <literal>{...}</literal> have to be - within the same compile unit (file or <function>eval</function>ed - string). + Ainda &eacute; permitido incluir c&oacute;digos adicionaisdentro dos la&ccedil;os ou + estruturas de controle, somente os controles chaves e os correspondentes + <literal>(....)</literal> tem que estar compilados na mesma unidade + (arquivo ou <function>eval</function>ed string). </para> <para> - This should not harm to much as spreading code like this should be - considered as very bad style anyway. + Isto n&atilde;o deve prejudicar muito considerando que um c&oacute;digo como este + &eacute; considerado mal feito de qualquer maneira. </para> <para> - Another thing no longer possible, though rarely seen in PHP 3 - code is returning values from a required file. Returning a value - from an included file is still possible. + Outra coisa que n&atilde;o &eacute; mais poss&iacute;vel, e que &eacute; raramente visto em um c&oacute;digo + PHP 3 &eacute; o retorno de valores de um requerido arquivo. Retornar valores + de um arquivo inclu&iacute;do ainda &eacute; poss&iacute;vel. </para> </section> <section id='migration4.error-reporting'> - <title>Error reporting</title> + <title>Relatório de erros</title> <section id='migration4.error-reporting.config'> - <title>Configuration changes</title> + <title>Mudan&ccedil;as na Configura&ccedil;&atilde;o</title> <para> - With PHP 3 the error reporting level was set as a simple - numeric value formed by summing up the numbers related to - different error levels. Usual values where 15 for reporting all - errors and warnings or 7 for reporting everything but simple - notice messages reporting bad style and things like that. - </para> - <para> - PHP 4 has a larger set of error and warning levels and comes with a - configuration parser that now allows for symbolic constants to be used - for setting the intended behavior. - </para> - <para> - Error reporting level should now be configured by explicitly - taking away the warning levels you do not want to generate error - messages by x-oring them from the symbolic constant - <literal>E_ALL</literal>. Sounds complicated? Well, lets say you - want the error reporting system to report all but the simple - style warnings that are categorized by the symbolic constant - <literal>E_NOTICE</literal>. Then you'll put the following into - your &php.ini;: <literal>error_reporting = - E_ALL &amp; ~ ( E_NOTICE )</literal>. If you want to suppress - warnings too you add up the appropriate constant within the - braces using the binary or operator '|': - <literal>error_reporting= E_ALL &amp; ~ ( E_NOTICE | E_WARNING - )</literal>. + O relat&oacute;rio de erro do PHP 3 foi ajustado para um simples + valor n&uacute;mero formado pela soma de n&uacute;meros relacionados aos + diferentes n&iacute;veis de erro. Valores usuais onde 15 para relatar + todos os erros e mensagens ou 7 para relatar qualquer coisa mas + simples observa&ccedil;&atilde;o ao mal estilo e coisas como esta. + </para> + <para> + PHP 4 cont&eacute;m um maior n&iacute;vel de erros e avisos e vem com uma + configura&ccedil;&atilde;o do parser que agora permite que constantes simb&oacute;licas + sejam usadas para para ajustar ao comportamente pretendido. + </para> + <para> + O n&iacute;vel do relat&oacute;rio de erro agora pode ser configurado explicitamente + removendo os n&iacute;veis de advert&ecirc;ncia que voc&ecirc; n&atilde;o quer gerar nas suas + mensagens de erro x-oring da constante simb&oacute;lica <literal>E_ALL</literal>. + Parece complicado? Bem, vamos dizer que voc&ecirc; quer todas as advert&ecirc;ncias + categorizadas na constante simb&oacute;lica <literal>E_NOTICE</literal>. Ent&atilde;o voc&ecirc; + dever&aacute; colocar o seguinte em seu &php.ini;: <literal>error_reporting = + E_ALL &amp; - ( E_NOTICE )</literal>. Se voc&ecirc; quiser suprir as + advert&ecirc;ncias voc&ecirc; deve adicionar a constante apropriada dentro do + par&ecirc;ntese usando o operador '|': + <literal>erro_reporting = E_ALL &amp; ~ ( E_NOTICE | E_WARNING )</literal>. </para> <warning> <para> - When upgrading code or servers from PHP 3 to PHP 4 you should - check these settings and calls to - <function>error_reporting</function> or you might disable - reporting the new error types, especially E_COMPILE_ERROR. This - may lead to empty documents without any feedback of what happened - or where to look for the problem. + Ao atualizar c&oacute;digos ou servidores do PHP 3 para PHP 4 voc&ecirc; + deve checar as configura&ccedil;&otilde;es e chamadas ao <function>error_reporting</function> + ou voc&ecirc; deve desabilitar os novos tipos de relat&oacute;rio de erro, + especialmente E_COMPILE_ERROR. Isto pode ocasionar a limpeza de + documents sem nenhuma resposta do que ocorreu ou onde procurar + pelo problema. </para> </warning> <warning> <para> - Using the old values 7 and 15 for setting up error reporting is - a very bad idea as this suppresses some of the newly added error - classes including parse errors. This may lead to very strange - behavior as scripts might no longer work without error messages - showing up anywhere. + Usando valores menores que 7 ou 15 para ajustar o relat&oacute;rio + de erro n&atilde;o &eacute; uma boa id&eacute;ia porque pode suprir algumas das + classes de erros adicionadas no parser de erros. Isto pode causar + um comportamento estranho com os scripts e tamb&eacute;m n&atilde;o ir&aacute; + mostrar nenhuma mensagem de erro em nenhum lugar. </para> <para> - This has lead to a lot of unreproducible bug reports in the - past where people reported script engine problems they were not - capable to track down while the &true; case was usually some - missing '}' in a required file that the parser was not able to - report due to a misconfigured error reporting system. + No passa isto causou muitas inconveni&ecirc;ncias porque as + pessoas relatavam problemas nos scripts e na verdade + n&atilde;o eram capazes de consertar erros comuns, como a falta de + um '}' requerido em um arquivo que era passado e que o + parser n&atilde;o era capaz de reportar um erro que era apenas + um erro de uma falta de configura&ccedil;&atilde;o no sistema. </para> <para> - So checking your error reporting setup should be the first thing - to do whenever your scripts silently die. The Zend engine can - be considered mature enough nowadays to not cause this kind of - strange behavior. + Ent&atilde;o checar a sua configura&ccedil;&atilde;o do relat&oacute;rio de erros + deve ser a primeira coisa a fazer quando os seus scripts + causam erros silenciosos. O engine da Zend pode ser + considerado maduro o bastante nos dias atuais para n&atilde;o + causar estes tipos de erros estranhos. </para> </warning> </section> <section id='migration4.error-reporting.additions'> - <title>Additional warning messages</title> + <title>Mensagens de advert&ecirc;ncia adicionais</title> <para> - A lot of existing PHP 3 code uses language constructs that - should be considered as very bad style as this code, while doing - the intended thing now, could easily be broken by changes in - other places. PHP 4 will output a lot of notice messages in - such situations where PHP 3 didn't. The easy fix is to just - turn off E_NOTICE messages, but it is usually a good idea to fix - the code instead. - </para> - <para> - The most common case that will now produce notice messages is the - use of unquoted string constants as array indices. Both PHP 3 - and 4 will fall back to interpret these as strings if no - keyword or constant is known by that name, but whenever a - constant by that name had been defined anywhere else in the code - it might break your script. This can even become a security risk - if some intruder manages to redefine string constants in a way - that makes your script give him access rights he wasn't intended - to have. So PHP 4 will now warn you whenever you use unquoted - string constants as for example in - <literal>$_SERVER[REQUEST_METHOD]</literal>. Changing it - to <literal>$_SERVER['REQUEST_METHOD']</literal> will - make the parser happy and greatly improve the style and security - of your code. + Muitos c&oacute;digos PHP 3 existentes usam uma linguagem de estrutura + que pode ser considerado um c&oacute;digo mal formatado, o que pode + tornar as coisas f&aacute;ceis agora, pode facilmente ser quebrado + por mudan&ccedil;as em outros lugares. PHP 4 exibe muitas mensagens + de advert&ecirc;ncia em situa&ccedil;&otilde;es onde o PHP 3 n&atilde;o o fazia. O jeito + f&aacute;cil de consertar isto &eacute; setar para off as mensagens E_NOTICE, + mas geralmente &eacute; sempre bom consertar o c&oacute;digo. + </para> + <para> + O caso mais comum que agora ir&aacute; produzir mensagens de advert&ecirc;ncia + &eacute; o uso de constantes de strings n&atilde;o quotadas como &iacute;ndices de array. + Ambos PHP 3 e PHP 4 tentar&atilde;o interpretarar isto como se fosse strings + se nenhuma palavra ou constante for conhecida pelo nome, mas sempre que + uma constante por esse nome for definida em qualquer lugar do c&oacute;digo + ela pode causar erros no script. Isto pode se tornar um risco de + seguran&ccedil;a se um invasor redefinir as strings constantes &agrave; um + caminho que faz o seu script dar as permiss&otilde;es corretas que ele + n&atilde;o deveria ter. Ent&atilde;o o PHP 4 agora avisa voc&ecirc; sempre que + voc&ecirc; usar strings constantes n&atilde;o quotadas por exemplo no + <literal>$_SERVER[REQUEST_METHOD]</literal>. Altere isto para + <literal>$_SERVER['REQUEST_METHOD']</literal> que far&aacute; + com que o parser fique feliz e melhorar&aacute; extremamente o + estilo e seguran&ccedil;a do seu c&oacute;digo. </para> <para> - Another thing PHP 4 will now tell you about is the use of - uninitialized variables or array elements. + Outra coisa que o PHP 4 agora lhe informa &eacute; sobre o uso + de vari&aacute;veis ou elementos de array n&atilde;o inicializados. </para> </section> </section> <section id='migration4.initializers'> - <title>Initializers</title> + <title>Inicializadores</title> <para> - Static variable and class member initializers only accept scalar - values while in PHP 3 they accepted any valid expression. This - is, once again, due to the split between parsing and execution as - no code has yet been executed when the parser sees the - initializer. + Os inicializadores de vari&aacute;veis est&aacute;ticas e membros de classes + aceitam somente valores escalares enquanto no PHP 3 eles aceitavam + qualquer express&atilde;o v&aacute;lida. Isto &eacute;, mais uma vez, devido ao corte entre + a execu&ccedil;&atilde;o e o parsing como nenhum c&oacute;digo executado quando o parser + v&ecirc; o inicializador. </para> <para> - For classes you should use constructors to initialize member - variables instead. For static variables anything but a simple - static value rarely makes sense anyway. + Para classes voc&ecirc; deve usar construtores para inicializar + membros ao inv&eacute;s de vari&aacute;veis. Para vari&aacute;veis est&aacute;ticas + pode-se usar qualquer coisa mas raramente uma simples + vari&aacute;vel est&aacute;tira faz algum sentido. </para> </section> <section id='migration4.empty'> <title><literal>empty("0")</literal></title> <para> - The perhaps most controversial change in behavior has happened to the - behavior of the <function>empty</function>. A String containing - only the character '0' (zero) is now considered empty while it - wasn't in PHP 3. + Talvez a mudan&ccedil;a mais controversa no comportamento aconteceu na fun&ccedil;&atilde;o + <function>empty</function>. Uma string que cont&eacute;m somente caracteres + ' 0 ' (zero) agora &eacute; considerada vazia enquanto no PHP 3 ela n&atilde;o era. </para> <para> - This new behavior makes sense in web applications, with all input - fields returning strings even if numeric input is requested, and - with PHP's capabilities of automatic type conversion. But on the - other had it might break your code in a rather subtle way, - leading to misbehavior that is hard to track down if you do not - know about what to look for. + Estes novos comportamentos fazem sentido em aplicativos web, com todos + aqueles campos retornando strings mesmo se entradas n&uacute;mericas s&atilde;o requisitadas, + e com as capacidades do PHP automaticamente converter os tipos. Mas + por outro lado isto pode gerar problemas no seu c&oacute;digo de uma + maneira totalmente pertubadora, conduzindo ao um estranho comportamento + que &eacute; duro de consertar se voc&ecirc; n&atilde;o souber o que voc&ecirc; procura. </para> </section> <section id='migration4.missing'> - <title>Missing functions</title> + <title>Fun&ccedil;&otilde;es abandonadas</title> <para> - While PHP 4 comes with a lot of new features, functions and - extensions, you may still find some functions from version 3 - missing. A small number of core functions has vanished because - they do not work with the new scheme of splitting parsing and - execution as introduced into 4 with the Zend engine. Other - functions and even complete extensions have become obsolete as - newer functions and extensions serve the same task better and/or - in a more general way. Some functions just simply haven't been - ported yet and finally some functions or extensions may be missing - due to license conflicts. + Enquanto o PHP 4 vem com uma s&eacute;rie de novas caracter&iacute;sticas, + fun&ccedil;&otilde;es e extens&otilde;es, voc&ecirc; talvez encontre algumas fun&ccedil;&otilde;es da + vers&atilde;o 3 que n&atilde;o existem mais. Um pequeno n&uacute;mero de fun&ccedil;&otilde;es + do n&uacute;cleo desapareceu porque elas n&atilde;o funcionavam com o novo + sistema de execu&ccedil;&atilde;o e parsing introduzido na vers&atilde;o 4 com a + Zend engine. Outras fun&ccedil;&otilde;es e mesmo extens&otilde;es se tornaram + obsoletas para as novas fun&ccedil;&otilde;es e extens&otilde;es que servem a + mesma tarefa melhor e/ou de uma maneira geral. Algumas fun&ccedil;&otilde;es + simplesmente n&atilde;o foram portadas ainda e finalmente algumas + fun&ccedil;&otilde;es ou extens&otilde;es podem ter sido retiradas por conflitos + de licen&ccedil;a. </para> <section id='migration4.missing.concept'> - <title>Functions missing due to conceptual changes</title> + <title>Funções abandonadas devido à mudanças conceptuais</title> <para> - As PHP 4 now separates parsing from execution it is no longer - possible to change the behavior of the parser (now embedded in - the Zend engine) at runtime as parsing already happened by - then. So the function <function>short_tags</function> no longer - exists. You can still change the parsers behavior by setting - appropriate values in the &php.ini; file. + Como o PHP 4 agora separa o parsing da execu&ccedil;&atilde;o n&atilde;o &eacute; mais poss&iacute;vel + alterar o comportamento do parser (agora embutido na Zend engine) + na hora da execu&ccedil;&atilde;o quando o parsing j&aacute; aconteceu. Ent&atilde;o a fun&ccedil;&atilde;o + <function>short_tags</function> n&atilde;o existe mais. Voc&ecirc; ainda + pode mudar o comportamento dos parsers setando o valor + propriedade no arquivo &php.ini. </para> <para> - Another feature of PHP 3 that is not a part of PHP 4 is the bundled - debugging interface. There are third-party add-ons for the Zend engine - which add similar functionality. + Outra caracter&iacute;sticas do PHP 3 que n&atilde;o faz parte do PHP 4 &eacute; + a rela&ccedil;&atilde;o embutida de eliminar erros. Existem add-ons de terceiros + para a Zend engine que adicionam um funcionamento similar. </para> </section> <section id='migration4.deprecate'> - <title>Deprecate functions and extensions</title> + <title>Depcritamento de fun&ccedil;&otilde;es e extens&otilde;es</title> <para> - The Adabas and Solid database extensions are no more. Long live - the unified ODBC extension instead. + As extens&otilde;es dos banco de dados Adabas e Solid n&atilde;o existem mais. + Ao in&eacute;s delas foi unificado o ODBC. </para> </section> <section id='migration4.unset'> - <title>Changed status for <function>unset</function></title> + <title>Mudan&ccedil;a de status para <function>unset</function></title> <para> - <function>unset</function>, although still available, is - implemented as a language construct rather than a function. + <function>unset</function>, embora ainda dispon&iacute;vel, &eacute; + implementado como um construtor de linguagem melhor que uma fun&ccedil;&atilde;o. </para> <para> - This does not have any consequences on the behavior of - <function>unset</function>, but testing for "unset" using - <function>function_exists</function> will return &false; as it would with - other language constructs that look like functions such as - <function>echo</function>. + Isto n&atilde;o tem nenhumas conseq&uuml;&ecirc;ncias no comportamento < de function>unset, mas testar para "unset" usando < function>function_exists retornar&aacute; o &false; porque com outras constru&ccedil;&otilde;es da l&iacute;ngua que olham como fun&ccedil;&otilde;es tais como < function>echo. + Isto n&atilde;o interfere em nada no comportamento do + <function>unset</function>, mas testar "unset" usando + <function>function_exists</function> retornar&aacute; &false; + porque com outros construtores de linguagens que observam + func&ccedil;&otilde;es tais como o <function>echo</function>. </para> <para> - Another more practical change is that it is no longer possible to - call <function>unset</function> indirectly, that is - <literal>$func="unset"; $func($somevar)</literal> won't work - anymore. + Uma otura mudan&ccedil;a mais pr&aacute;tica &eacute; que n&atilde;o &eacute; mais poss&iacute;vel chamar + <function>unset</function> indiretamente, isso &eacute;, <literal>$func="unset"; $func($algumavar)</literal> + n&atilde;o ir&aacute; mais funcionar. </para> </section> </section> <section id='migration4.extensions'> - <title>PHP 3 extension</title> + <title>Extens&otilde;es PHP 3</title> <para> - Extensions written for PHP 3 will not work with PHP 4, neither as binaries - nor at the source level. It is not difficult to port extensions to PHP 4 - if you have access to the original source. A detailed description of the - actual porting process is not part of this text. + Extens&otilde;es escritas para o PHP 3 n&atilde;o ir&atilde;o funcionar com o PHP 4, + nem como bin&aacute;rias nem no c&oacute;digo fonte. N&atilde;o &eacute; dif&iacute;cil portar estas + extens&otilde;es para o PHP 4 se vc&ecirc; tiver acesso aos fontes originais. + Uma descri&ccedil;&atilde;o detalhada do processo de porta&ccedil;&atilde;o n&atilde;o faz parte deste + texto. </para> </section> <section id='migration4.strings'> - <title>Variable substitution in strings</title> + <title>Substitui&ccedil;&atilde;o de vari&aacute;veis nas strings</title> <para> - PHP 4 adds a new mechanism to variable substitution in - strings. You can now finally access object member variables and - elements from multidimensional arrays within strings. + O PHP 4 adiciona um novo mecanimos para a substitui&ccedil;&atilde;o + de vari&aacute;veis em strings. Agora voc&ecirc; finalmente pode acessar + as vari&aacute;veis de um objeto membro e seus elementos de um + array multidimensional dentro de strings. </para> <para> - To do so you have to enclose your variables with curly braces with - the dollar sign immediately following the opening brace: + Para fazer isso voc&ecirc; tem que incluir nas suas vari&aacute;veis chaves + com o s&iacute;mbolo da moeda imediatamente ap&oacute;s a chave de abertura: <literal>{$...}</literal> </para> <para> - To embed the value of an object member variable into a string you - simply write <literal>"text {$obj-&gt;member} text"</literal> while - in PHP 3 you had to use something like <literal>"text - ".$obj-&gt;member." text"</literal>. + Para embutir o valor de um objeto membro de uma vari&aacute;vel + dentro de uma string simplesmente escreva <literal>"texto {$obj-&gt;membro} texto"</literal> + enquanto no PHP 3 voc&ecirc; tinha que usar uma coisa como esta + <literal>"texto ".$obj-&gt;membro." texto"</literal>. </para> <para> - This should lead to more readable code, while it may break - existing scripts written for PHP 3. But you can easily check for - this kind of problem by checking for the character combination - <literal>{$</literal> in your code and by replacing it with - <literal>\{$</literal> with your favorite search-and-replace - tool. - </para> + Isto gera um c&oacute;digo mais leg&iacute;vel, mas pode gerar problemas + em scripts existentes escritos para o PHP 3. Mas + voc&ecirc; pode facilmente char este tipo de problema procurando + por uma combina&ccedil;&atilde;o de caracteres <literal>{$</literal> + no seu c&oacute;digo e substituindo eles por + <literal>\{$</literal> usando sua ferramenta de + procura-e-substitui&ccedil;&atilde;o favorita. + </para> </section> <section id='migration4.cookies'> <title>Cookies</title> <para> - PHP 3 had the bad habit of setting cookies in the reverse order - of the <function>setcookie</function> calls in your code. PHP 4 - breaks with this habit and creates the cookie header lines in - exactly the same order as you set the cookies in the code. + O PHP 3 tinha um mau h&aacute;bito de configurar os cookies na ordem + reversa das chamadas <function>setcookie</function> no seu c&oacute;digo. + O PHP 4 inibiu este mau h&aacute;bito e cria as linhas de cabe&ccedil;alhos + dos cookies exatamente na mesma ordem que voc&ecirc; definie no + seu c&oacute;digo. </para> <para> - This might break some existing code, but the old behaviour was so - strange to understand that it deserved a change to prevent further - problems in the future. + Isto pode gerar problemas no seu c&oacute;digo existente, mas o velho + comportamente era t&atilde;o estranho de se entender que mereceu + uma mudan&ccedil;a para previnir futuros problemas. </para> </section> <section id='migration4.variables'> - <title>Handling of global variables</title> + <title>Manipula&ccedil;&atilde;o de vari&aacute;veis globais</title> <para> - While handling of global variables had the focus on to be easy in - PHP 3 and early versions of PHP 4, the focus has changed to be more - secure. While in PHP 3 the following example worked fine, in PHP 4 it - has to be unset($GLOBALS["id"]);. This is only one issue of global - variable handling. You should always have used $GLOBALS, with - newer versions of PHP 4 you are forced to do so in most cases. - Read more on this subject in the <link linkend="references.global"> - <literal>global</literal> references section</link>. + A manipula&ccedil;&atilde;o de vari&aacute;veis globais tinha o foco de ser + f&aacute;cil no PHP 3 e vers&otilde;es posteriores &agrave; PHP 4, mas este + foco mudou por medidas de seguran&ccedil;a. Enquanto em um + script PHP 3 o exemplo a seguir funciona normalmente, + no PHP 4 tem que se usar unset($GLOBALS["id"]);. Isto + &eacute; apenas uma introdu&ccedil;&atilde;o da manipula&ccedil;&atilde;o de vari&aacute;veis globais. + Voc&ecirc; dever&aacute; sempre usar $GLOBALS, com as novas vers&otilde;es + do PHP 4 voc&ecirc; &eacute; for&ccedil;ado a fazer isto na maioria dos casos. + Leia mais sobre este assunto em <link linkend="references.global">. </para> <example> - <title>Migration of global variables</title> + <title>Migra&ccedil;&atilde;o das vari&aacute;veis globais</title> <programlisting role="php"> <![CDATA[ <?php Index: phpdoc/en/appendices/migration.xml diff -u phpdoc/en/appendices/migration.xml:1.19 phpdoc/en/appendices/migration.xml:1.20 --- phpdoc/en/appendices/migration.xml:1.19 Wed May 1 04:53:07 2002 +++ phpdoc/en/appendices/migration.xml Wed Nov 20 07:19:11 2002 @@ -1,95 +1,94 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.19 $ --> +<!-- $Revision: 1.20 $ --> <appendix id="migration"> - <title>Migrating from PHP/FI 2 to PHP 3</title> + <title>Mirgrando do PHP/FI para o PHP 3</title> <section id="migration.about"> - <title>About the incompatibilities in 3.0</title> + <title>Sobre as incompatibilidades do 3.0</title> <simpara> - PHP 3.0 is rewritten from the ground up. It has a proper parser - that is much more robust and consistent than 2.0's. 3.0 is also - significantly faster, and uses less memory. However, some of - these improvements have not been possible without compatibility - changes, both in syntax and functionality. + PHP 3.0 foi totalmente reescrito. Ele tem um parser apropriado + que &eacute; muito mais robusto e consistente que o da vers&atilde;o 2.0. 3.0 + &eacute; tamb&eacute;m significamente mais r&aacute;pido, e usa menos mem&oacute;ria. Entretanto + algumas dessas melhorias n&atilde;o seriam poss&iacute;veis sem mudan&ccedil;as na compatibilidade, + na sintaxe e na funcionalidade. </simpara> <simpara> - In addition, PHP's developers have tried to clean up both PHP's - syntax and semantics in version 3.0, and this has also caused some - incompatibilities. In the long run, we believe that these changes - are for the better. + Al&eacute;m do mais, os desenvolvedores do PHP tentaram limpar ambas + sintaxe e sem&acirc;nticas da vers&atilde;o 3.0 do PHP, e isto tamb&eacute;m traz algumas + incompatbilidades. A longo prazo, n&oacute;s acreditamos que estas mudan&ccedil;as + s&atilde;o para melhor. </simpara> <simpara> - This chapter will try to guide you through the incompatibilities - you might run into when going from PHP/FI 2.0 to PHP 3.0 and help - you resolve them. New features are not mentioned here unless - necessary. + Este cap&iacute;tulo tentar&aacute; guiar voc&ecirc; com as incompatibilidades que voc&ecirc; + encontrar&aacute; quando estiver migrando do PHP/FI 2.0 para o PHP 3.0 e + ajudar&aacute; a resolver elas. Novas caracter&iacute;sticas n&atilde;o s&atilde;o mencionadas aqui + a menos que seja necess&aacute;rio. </simpara> <simpara> - A conversion program that can automatically convert your old - PHP/FI 2.0 scripts exists. It can be found in the - <filename class="directory">convertor</filename> subdirectory of the PHP 3.0 - distribution. This program only catches the syntax changes though, - so you should read this chapter carefully anyway. + Um programa que converte automaticamente seus scripts em PHP/FI 2.0 existe. + Ele pode ser encontrado no subdiret&oacute;rio <filename class="directory">convertor</filename> + da distribui&ccedil;&atilde;o do PHP 3.0. Este programa apenas capta altera&ccedil;&otilde;es de sintaxe, + portanto voc&ecirc; deve ler atentamente este cap&iacute;tulo. </simpara> </section> <section id="migration.startendtags"> - <title>Start/end tags</title> + <title>Tags de Come&ccedil;o/fim</title> <para> - The first thing you probably will notice is that PHP's start and end - tags have changed. The old <literal>&lt;? &gt;</literal> form has been - replaced by three new possible forms: + A primeira coisa que voc&ecirc; provavelmente ir&aacute; reparar &eacute; que as tags de + come&ccedil;o e fim do PHP mudaram. O velho foi <literal>&lt;? &gt;</literal> + modificado para tr&ecirc;s formas poss&iacute;veis: <example> - <title>Migration: old start/end tags</title> + <title>Migrando: da velha tag come&ccedil;o/fim</title> <programlisting role="php"> <![CDATA[ -<? echo "This is PHP/FI 2.0 code.\n"; ?> +<? echo "Este &eacute; um c&oacute;digo em PHP/FI 2.0.\n"; > ]]> </programlisting> </example> - As of version 2.0, PHP/FI also supports this variation: + Como na vers&atilde;o 2.0, PHP/FI tamb&eacute;m suporta esta varia&ccedil;&atilde;o: <example> - <title>Migration: first new start/end tags</title> + <title>Migrando: primeira forma das tags come&ccedil;o/fim</title> <programlisting role="php"> <![CDATA[ -<? echo "This is PHP 3.0 code!\n"; ?> +<? echo "Este &eacute; um c&oacute;digo em PHP 3.0!\n"; ?> ]]> </programlisting> </example> - Notice that the end tag now consists of a question mark and a - greater-than character instead of just greater-than. However, if - you plan on using XML on your server, you will get problems with - the first new variant, because PHP may try to execute the XML - markup in XML documents as PHP code. Because of this, the - following variation was introduced: + Repare que a tag de fechamento agora consiste em um sinal de interroga&ccedil;&atilde;o e uma + tag de fechamento e n&atilde;o apenas em uma tag de fechamento. Entretanto, se + voc&ecirc; planeja usar XML no seu servidor, voc&ecirc; obeter&aacute; alguns problemas com a + nova varia&ccedil;&atilde;o, porque o PHP pode tentar executar as tags de marca&ccedil;&atilde;o dos + documentos em XML como c&oacute;digos PHP. Por causa disto, a seguinte modifica&ccedil;&atilde;o + foi adicionada: <example> - <title>Migration: second new start/end tags</title> + <title>Migrando: segunda forma das tags come&ccedil;o/fim</title> <programlisting role="php"> <![CDATA[ -<?php echo "This is PHP 3.0 code!\n"; ?> +<?php echo "Este &eacute; um c&oacute;digo em PHP 3.0!\n"; ?> ]]> </programlisting> </example> - Some people have had problems with editors that don't understand - the processing instruction tags at all. Microsoft FrontPage is one - such editor, and as a workaround for these, the following variation - was introduced as well: + Algumas pessoas obtiveram problemas com editores que n&atilde;o entendem + todas as tags de processamento. O Microsoft Frontpage &eacute; um destes editores, + e pensando nestes editores, foi adicionado mais uma modifica&ccedil;&atilde;o que &eacute; mostrada + abaixo: <example> - <title>Migration: third new start/end tags</title> + <title>Migrando: terceira forma das tags come&ccedil;o/fim</title> <programlisting role="php"> <![CDATA[ <script language="php"> - echo "This is PHP 3.0 code!\n"; + echo "Este &eacute; um c&oacute;digo em PHP 3.0!\n"; </script> ]]> @@ -99,67 +98,66 @@ </section> <section id="migration.if-endif"> - <title>if..endif syntax</title> + <title>sintaxe if..endif</title> <para> - The `alternative' way to write if/elseif/else statements, using if(); - elseif(); else; endif; cannot be efficiently implemented without - adding a large amount of complexity to the 3.0 parser. Because of - this, the syntax has been changed: + A maneira 'alternativa' de escrever as instru&ccedil;&otilde;es if/elseif/else , usando if(); + elseif(); else; endif; n&atilde;o puderam ser eficientemente implementadas sem adicionar + uma quantidade grande de complexidade ao parser 3.0. Por causa disso, a sintaxe foi + alterada para: <example> - <title>Migration: old if..endif syntax</title> + <title>Migrando: velha sintaxe if..endif</title> <programlisting role="php"> <![CDATA[ if ($foo); - echo "yep\n"; + echo "sim\n"; elseif ($bar); - echo "almost\n"; + echo "quase\n"; else; - echo "nope\n"; + echo "n&atilde;o\n"; endif; ]]> </programlisting> </example> <example> - <title>Migration: new if..endif syntax</title> + <title>Migrando: nova sintaxe if..endif</title> <programlisting role="php"> <![CDATA[ if ($foo): - echo "yep\n"; + echo "sim\n"; elseif ($bar): - echo "almost\n"; + echo "quase\n"; else: - echo "nope\n"; + echo "n&atilde;o\n"; endif; ]]> </programlisting> </example> - Notice that the semicolons have been replaced by colons in all - statements but the one terminating the expression (endif). + Repare que todos os pontos-e-v&iacute;rgulas foram trocados por dois-pontos em todas + as instru&ccedil;&otilde;es, exceto na instru&ccedil;&atilde;o de fechamento (endif). </para> </section> <section id="migration-while"> - <title>while syntax</title> + <title>sintaxe while</title> <para> - Just like with if..endif, the syntax of while..endwhile has changed - as well: + Assim como o if...endif, a sintaxe do while...endwhile foi alterada: <example> - <title>Migration: old while..endwhile syntax</title> + <title>Migrando: a velha sintaxe do while..endwhile</title> <programlisting role="php"> <![CDATA[ -while ($more_to_come); +while ($mais_a_vir); ... endwhile; ]]> </programlisting> </example> <example> - <title>Migration: new while..endwhile syntax</title> + <title>Migrando: nova sintaxe do while..endwhile</title> <programlisting role="php"> <![CDATA[ -while ($more_to_come): +while ($mais_a_vir): ... endwhile; ]]> @@ -168,22 +166,22 @@ </para> <warning> <simpara> - If you use the old while..endwhile syntax in PHP 3.0, - you will get a never-ending loop. + Se voc&ecirc; usar a velha sintaxe do while...endwhile no PHP 3.0, + voc&ecirc; ir&aacute; obter um loop que nunca-termina. </simpara> </warning> </section> <section id="migration.expr"> - <title>Expression types</title> + <title>Tipos de Express&otilde;es</title> <simpara> - PHP/FI 2.0 used the left side of expressions to determine what type - the result should be. PHP 3.0 takes both sides into account when - determining result types, and this may cause 2.0 scripts to behave - unexpectedly in 3.0. + O PHP/FI 2.0 usa o lado esquerdo das express&otilde;es para determinar qual o tipo + de resultado que deve retornar. O PHP 3.0 examina ambos os lados quando + determina os tipos de resultados, e isto pode fazer com que scripts da vers&atilde;o + 2.0 comportem-se inesperadamente. </simpara> <para> - Consider this example: + Considere este exemplo: <informalexample> <programlisting role="php"> <![CDATA[ @@ -199,20 +197,17 @@ </programlisting> </informalexample> - In PHP/FI 2.0, this would display both of $a's indices. In PHP - 3.0, it wouldn't display anything. The reason is that in PHP 2.0, - because the left argument's type was string, a string comparison - was made, and indeed <literal>""</literal> does not equal - <literal>"0"</literal>, and the loop went through. In PHP 3.0, - when a string is compared with an integer, an integer comparison is - made (the string is converted to an integer). This results in - comparing <literal>atoi("")</literal> which is - <literal>0</literal>, and <literal>variablelist</literal> which is - also <literal>0</literal>, and since <literal>0==0</literal>, the - loop doesn't go through even once. + No PHP/FI 2.0, isto mostraria ambos os &iacute;ndices de $a. No PHP 3.0, + isto n&atilde;o mostraria nada. A raz&atilde;o &eacute; que no PHP 2.0, &eacute; porque os argumentos + da esquerda eram do tipo string, ent&atilde;o uma compara&ccedil;&atilde;o de string foi feita, + e certamente <literal>""</literal> n&atilde;o &eacute; igual &agrave; <literal>"0"</literal>, e o + la&ccedil;o &eacute; completado. No PHP 3.0, quando uma string &eacute; comparada com um inteiro, uma + compara&ccedil;&atilde;o de inteiro &eacute; feita (a string &eacute; convertida para inteiro). Isto resultado em uma + compara&ccedil;&atilde;o em que <literal>atoi("")</literal> &eacute; <literal>0</literal>, e <literal>variablelist</literal> + tamb&eacute;m &eacute; <literal>0</literal>, deste que <literal>0==0</literal>, o loop n&atilde;o executa mais de uma vez. </para> <para> - The fix for this is simple. Replace the while statement with: + A corre&ccedil;&atilde;o para iso &eacute; simples. Troque aquele while por: <informalexample> <programlisting role="php"> <![CDATA[ @@ -224,60 +219,57 @@ </section> <section id="migration.errors"> - <title>Error messages have changed</title> + <title>Mensagens de erro foram alteradas</title> <simpara> - PHP 3.0's error messages are usually more accurate than 2.0's were, - but you no longer get to see the code fragment causing the error. - You will be supplied with a file name and a line number for the - error, though. + No PHP 3.0 as mensagens de erro geralmente s&atilde;o mais exatadas do que as do PHP 2.0, + mas voc&ecirc; n&atilde;o ver&aacute; mais o fragmento de c&oacute;digo que cont&eacute;m o erro. Voc&ecirc; ser&aacute; notificado + com o nome do arquivo e o n&uacute;mero da linha onde ocorreu o erro. </simpara> </section> <section id="migration.booleval"> <title>Short-circuited boolean evaluation</title> <simpara> - In PHP 3.0 boolean evaluation is short-circuited. This means that - in an expression like <literal>(1 || test_me())</literal>, the - function <function>test_me</function> would not be executed since - nothing can change the result of the expression after the - <literal>1</literal>. + No PHP 3.0 a avalia&ccedil;&atilde;o booleana &eacute; short-circuited. Isto significa que + uma express&atilde;o como esta <literal>(1 || teste_me())</literal>, da fun&ccedil;&atilde;o + <function>teste_me</function> n&atilde;o seria executada porque nada pode mudar + o resultado da express&atilde;o ap&oacute;s <literal>1</literal>. </simpara> <simpara> - This is a minor compatibility issue, but may cause unexpected - side-effects. + Esta &eacute; uma pequena incompatibilidade, mas poder&aacute; causar side-effects + inesperados. </simpara> </section> <section id="migration.truefalse"> - <title>Function &true;/&false; return values</title> + <title>Fun&ccedil;&otilde;es &true;/&false; retornam valores</title> <simpara> - Most internal functions have been rewritten so they return &true; - when successful and &false; when failing, as opposed to 0 and -1 in - PHP/FI 2.0, respectively. The new behaviour allows for more - logical code, like <literal>$fp = fopen("/your/file") or - fail("darn!");</literal>. Because PHP/FI 2.0 had no clear rules - for what functions should return when they failed, most such - scripts will probably have to be checked manually after using the - 2.0 to 3.0 convertor. + A maioria das fun&ccedil;&otilde;es foram reescritas sendo assim, retornam &true; + quando obt&eacute;m sucesso e &false; quando falham, ao contr&aacute;rio de 0 e -1 no + PHP/FI 2.0, respectivamente. O novo comportamento permite um c&oacute;digo mais + l&oacute;gico, como <literal>$fp = fopen("/seu/arquivo") or fail("merda!");</literal>. + Porque o PHP/FI 2.0 n&atilde;o tem regras claras quanto ao que a fun&ccedil;&atilde;o dever&aacute; retornar + caso falhe, muitos scripts provavelmente dever&atilde;o ser checados manualmente ap&oacute;s usar + o conversor de 2.0 para 3.0. </simpara> <para> <example> - <title>Migration from 2.0: return values, old code</title> + <title>Migrando do 2.0: retornando valores, c&oacute;digo antigo</title> <programlisting role="php"> <![CDATA[ -$fp = fopen($file, "r"); +$fp = fopen($arquivo, "r"); if ($fp == -1); - echo("Could not open $file for reading<br>\n"); + echo("N&atilde;o foi poss&iacute;vel abrir $arquivo para leitura<br>\n"); endif; ]]> </programlisting> </example> <example> - <title>Migration from 2.0: return values, new code</title> + <title>Migrando do 2.0: retornando valores, novo c&oacute;digo</title> <programlisting role="php"> <![CDATA[ -$fp = @fopen($file, "r") or print("Could not open $file for reading<br>\n"); +$fp = @fopen($arquivo, "r") or print("N&atilde;o foi poss&iacute;vel abrir $arquivo para leitura<br>\n"); ]]> </programlisting> </example> @@ -285,65 +277,60 @@ </section> <section id="migration-other"> - <title>Other incompatibilities</title> + <title>Outras incompatibilidades</title> <itemizedlist> <listitem><simpara> - The PHP 3.0 Apache module no longer supports Apache versions - prior to 1.2. Apache 1.2 or later is required. + O m&oacute;dulo do PHP 3.0 para o Apache n&atilde;o suporta vers&otilde;es anteriores &agrave; 1.2. + Apache 1.2 ou atual &eacute; requerido. </simpara></listitem> <listitem><simpara> - <function>echo</function> no longer supports a format string. - Use the <function>printf</function> function instead. + <function>echo</function> n&atilde;o suporta mais strings formatadas. + Use a fun&ccedil;&atilde;o <function>printf</function> para isto. </simpara></listitem> <listitem><simpara> - In PHP/FI 2.0, an implementation side-effect caused - <literal>$foo[0]</literal> to have the same effect as - <literal>$foo</literal>. This is not true for PHP 3.0. + No PHP/FI 2.0, uma execu&ccedil;&atilde;o "side-effect" faz com que <literal>$foo[0]</literal> + tenha o mesmo efeito que <literal>$foo</literal>. No PHP 3.0 isto n&atilde;o &eacute; verdadeiro. </simpara></listitem> <listitem> <simpara> - Reading arrays with <literal>$array[]</literal> is no longer - supported + Ler arrays com <literal>$array[]</literal> n&atilde;o &eacute; mais + suportado </simpara> <simpara> - That is, you cannot traverse an array by having a loop that does - <literal>$data = $array[]</literal>. Use <function>current</function> - and <function>next</function> instead. + Isto &eacute;, voc&ecirc; n&atilde;o pode atravessar um array fazendo um loop que cont&eacute;m <literal>$data = $array[]</literal>. + Ao inv&eacute;s disso use <function>current</function> e <function>next</function>. </simpara> <simpara> - Also, <literal>$array1[] = $array2</literal> does not - append the values of <literal>$array2</literal> to - <literal>$array1</literal>, but appends - <literal>$array2</literal> as the last entry of - <literal>$array1</literal>. See also multidimensional array - support. + Tamb&eacute;m, <literal>$array1[] = $array2</literal> n&atilde;o adiciona + valores de <literal>$array2</literal> &agrave; <literal>$array1</literal>, + mas adiciona <literal>$array2</literal> como a &uacute;ltima entrada de + <literal>$array1</literal>. Veja tamb&eacute;m o suporte ao array multidimensional. </simpara> </listitem> <listitem> <simpara> - <literal>"+"</literal> is no longer overloaded as a - concatenation operator for strings, instead it converts it's - arguments to numbers and performs numeric addition. Use - <literal>"."</literal> instead. + <literal>"+"</literal> n&atilde;o &eacute; mais considerado como um concatenador de + strings, ao inv&eacute;s disso &eacute; usado para converter argumentos para n&uacute;meros + e executar adi&ccedil;&otilde;es n&uacute;mericas. Use <literal>"."</literal> para concatenar. </simpara> </listitem> </itemizedlist> <example> - <title>Migration from 2.0: concatenation for strings</title> + <title>Migrando do 2.0: concatena&ccedil;&atilde;o de strings</title> <programlisting role="php"> <![CDATA[ echo "1" + "1"; ]]> </programlisting> <para> - In PHP 2.0 this would echo 11, in PHP 3.0 it would - echo 2. Instead use: + No PHP 2.0 isto retornaria echo 11, no PHP 3.0 isto + retornar&aacute; echo 2. Ao inv&eacute;s disso use: <programlisting role="php"> <![CDATA[ echo "1"."1"; @@ -358,7 +345,7 @@ </programlisting> </para> <para> - This would echo 2 in both PHP 2.0 and 3.0. + Isto ir&aacute; retornar echo 2 em ambas vers&otilde;es do PHP 2.0 e 3.0. <programlisting role="php"> <![CDATA[ $a = 1; @@ -366,7 +353,7 @@ echo $a.$b; ]]> </programlisting> - This will echo 11 in PHP 3.0. + Isto retornar&aacute; echo 11 no PHP 3.0. </para> </example> </section>
« previous php.doc (#969349827) next »