Files
smarty/docs/pt_BR/designers/language-custom-functions/language-function-math.xml

150 lines
4.9 KiB
XML
Raw Normal View History

2004-04-13 08:46:28 +00:00
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision$ -->
2004-10-02 12:49:29 +00:00
<!-- EN-Revision: 1.2 Maintainer: thomasgm Status: ready -->
2004-04-13 08:46:28 +00:00
<sect1 id="language.function.math">
<title>math</title>
<informaltable frame="all">
<tgroup cols="5">
<colspec colname="param" align="center" />
<colspec colname="type" align="center" />
<colspec colname="required" align="center" />
<colspec colname="default" align="center" />
<colspec colname="desc" />
<thead>
<row>
<entry>Nome do atributo</entry>
<entry>Tipo</entry>
<entry>Obrigat<EFBFBD>rio</entry>
2004-04-13 08:46:28 +00:00
<entry>Padr<EFBFBD>o</entry>
<entry>Descri<EFBFBD><EFBFBD>o</entry>
</row>
</thead>
<tbody>
<row>
<entry>equation</entry>
<entry>string</entry>
<entry>Sim</entry>
<entry><emphasis>n/a</emphasis></entry>
<entry>a equa<75><61>o <20> ser executar</entry>
2004-04-13 08:46:28 +00:00
</row>
<row>
<entry>format</entry>
<entry>string</entry>
<entry>N<EFBFBD>o</entry>
<entry><emphasis>n/a</emphasis></entry>
<entry>o formato do resultado (sprintf)</entry>
</row>
<row>
<entry>var</entry>
<entry>num<EFBFBD>rico</entry>
<entry>Sim</entry>
<entry><emphasis>n/a</emphasis></entry>
<entry>valor da vari<72>vel da equa<75><61>o</entry>
</row>
<row>
<entry>assign</entry>
<entry>string</entry>
<entry>N<EFBFBD>o</entry>
<entry><emphasis>n/a</emphasis></entry>
<entry>vari<EFBFBD>vel de template cuja sa<73>da ser<65> atribuida</entry>
</row>
<row>
<entry>[var ...]</entry>
<entry>num<EFBFBD>rica</entry>
<entry>Sim</entry>
<entry><emphasis>n/a</emphasis></entry>
<entry>valor da vari<72>vel da equa<75><61>o</entry>
</row>
</tbody>
</tgroup>
</informaltable>
<para>
math permite o desenhista de template fazer equa<75><61>es matem<65>ticas no template.
2004-04-13 08:46:28 +00:00
Qualquer vari<72>vel de template num<75>rica pode ser usada nas equa<75><61>es, e o resultado
<20> exibido no lugar da tag. As vari<72>veis usadas na equa<75><61>o s<>o passadas como par<61>metros,
que podem ser vari<72>veis de template
ou valores est<73>ticos. +, -, /, *, abs, ceil, cos,
exp, floor, log, log10, max, min, pi, pow, rand, round, sin, sqrt,
srans and tan s<>o todos os operadores v<>lidos. Verifique a documenta<74><61>o do PHP para
mais informa<6D><61>es acerca destas fun<75><6E>es matem<65>ticas.
</para>
<para>
Se voc<6F> fornece o atributo especial "assign", a sa<73>da da fun<75><6E>o matem<65>tica ser<65>
atribu<62>do para esta vari<72>vel
de template ao inv<6E>s de ser exibida para o template.
</para>
<note>
<title>Nota T<>cnica</title>
<para>
math <20> uma fun<75><6E>o de performance cara devido ao uso da fun<75><6E>o do php eval().
Fazendo a matem<65>tica no PHP <20> muito mais eficiente, ent<6E>o sempre <20> poss<73>vel fazer
os c<>lculos matem<65>ticos no PHP e lan<61>ar os resultados para o template. Definitivamente
evite chamadas de fun<75><6E>es de
matem<65>ticas repetitivamente, como dentro de loops de section.
</para>
</note>
<example>
<title>math</title>
<programlisting>
<![CDATA[
2004-04-13 08:46:28 +00:00
{* $height=4, $width=5 *}
{math equation="x + y" x=$height y=$width}
MOSTRA:
2004-04-13 08:46:28 +00:00
9
{* $row_height = 10, $row_width = 20, #col_div# = 2, assigned in template *}
{math equation="height * width / division"
height=$row_height
width=$row_width
division=#col_div#}
MOSTRA:
2004-04-13 08:46:28 +00:00
100
{* Voc<6F> pode usar parenteses *}
{math equation="(( x + y ) / z )" x=2 y=10 z=2}
MOSTRA:
2004-04-13 08:46:28 +00:00
6
{* voc<6F> pode fornecer um par<61>metro de formato em sprintf *}
{math equation="x + y" x=4.4444 y=5.0000 format="%.2f"}
MOSTRA:
2004-04-13 08:46:28 +00:00
9.44
]]>
</programlisting>
2004-04-13 08:46:28 +00:00
</example>
</sect1>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->