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

150 lines
4.9 KiB
XML
Raw Normal View History

2004-10-07 18:50:52 +00:00
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision$ -->
<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>Nombre del Atributo</entry>
<entry>Tipo</entry>
<entry>Requerido</entry>
<entry>Default</entry>
<entry>Descripci<EFBFBD>n</entry>
</row>
</thead>
<tbody>
<row>
<entry>equation</entry>
<entry>string</entry>
<entry>Si</entry>
<entry><emphasis>n/a</emphasis></entry>
<entry>La ecuaci<63>n a ejecutar</entry>
</row>
<row>
<entry>format</entry>
<entry>string</entry>
<entry>No</entry>
<entry><emphasis>n/a</emphasis></entry>
<entry>El formato del resultado (sprintf)</entry>
</row>
<row>
<entry>var</entry>
<entry>numeric</entry>
<entry>Si</entry>
<entry><emphasis>n/a</emphasis></entry>
<entry>Valor de la variable de la ecuaci<63>n</entry>
</row>
<row>
<entry>assign</entry>
<entry>string</entry>
<entry>No</entry>
<entry><emphasis>n/a</emphasis></entry>
<entry>Variable de template cuya salida sera asignada</entry>
</row>
<row>
<entry>[var ...]</entry>
<entry>numeric</entry>
<entry>Si</entry>
<entry><emphasis>n/a</emphasis></entry>
<entry>Valor de la variable de la ecuaci<63>n</entry>
</row>
</tbody>
</tgroup>
</informaltable>
<para>
math permite dise<73>ar ecuaciones matem<65>ticas dentro del template.
Cualquier variable num<75>rica del template puede ser usada en
ecuaciones, y el resultado es mostrado en lugar de la etiqueta.
Las variables usadas en ecuaciones son pasadas como par<61>metros,
que pueden ser variables de template o valores est<73>ticos.
+, -, /, *, abs, ceil, cos, exp, floor, log, log10, max, min,
pi, pow, rand, round, sin, sqrt, srans y tan son todos los
operadores validos. Verifique la documentaci<63>n de PHP para mas
informaci<63>n acerca de estas funciones matem<65>ticas.
</para>
<para>
Si usted proporciona el atributo especial "assign", la salida de la
funci<63>n matem<65>tica ser<65> atribuido a esta variable de template en
vez de ser mostrada en el template.
</para>
<note>
<title>Nota T<>cnica</title>
<para>
math es una funci<63>n de muy alto rendimiento debido a que se
puede usar con la funci<63>n eval() de PHP.
Hacer las matem<65>ticas en PHP es mucho mas eficiente, asi en
cualquier momento es posible hacer calculos matem<65>ticos en PHP
asignarlos a una variable y lanzar los resultados al template.
Def<65>nitivamente evite llamadas repetitivas de funciones
matem<65>ticas, dentro de los ciclos section.
</para>
</note>
<example>
<title>math</title>
<programlisting>
{* $height=4, $width=5 *}
{math equation="x + y" x=$height y=$width}
SALIDA:
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#}
SALIDA:
100
{* Usted puede usar parentesis *}
{math equation="(( x + y ) / z )" x=2 y=10 z=2}
SALIDA:
6
{* Usted puede asignar un par<61>metro de formato en sprintf *}
{math equation="x + y" x=4.4444 y=5.0000 format="%.2f"}
SALIDA:
9.44</programlisting>
</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
-->