2004-04-13 15:43:47 +00:00
|
|
|
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
|
|
|
|
<!-- $Revision$ -->
|
2004-05-23 15:50:53 +00:00
|
|
|
|
<!-- EN-Revision: 1.1 Maintainer: nobody Status: partial -->
|
|
|
|
|
|
<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>Nom attribut</entry>
|
|
|
|
|
|
<entry>Type</entry>
|
|
|
|
|
|
<entry>Requis</entry>
|
|
|
|
|
|
<entry>Defaut</entry>
|
|
|
|
|
|
<entry>Description</entry>
|
|
|
|
|
|
</row>
|
|
|
|
|
|
</thead>
|
|
|
|
|
|
<tbody>
|
|
|
|
|
|
<row>
|
|
|
|
|
|
<entry>equation</entry>
|
|
|
|
|
|
<entry>cha<EFBFBD>ne de caract<63>res</entry>
|
|
|
|
|
|
<entry>Oui</entry>
|
|
|
|
|
|
<entry><emphasis>n/a</emphasis></entry>
|
|
|
|
|
|
<entry>L'op<6F>ration <20> <20>x<EFBFBD>cuter</entry>
|
|
|
|
|
|
</row>
|
|
|
|
|
|
<row>
|
|
|
|
|
|
<entry>format</entry>
|
|
|
|
|
|
<entry>cha<EFBFBD>ne de caract<63>res</entry>
|
|
|
|
|
|
<entry>Non</entry>
|
|
|
|
|
|
<entry><emphasis>n/a</emphasis></entry>
|
|
|
|
|
|
<entry>Le format du r<>sultat (sprintf)</entry>
|
|
|
|
|
|
</row>
|
|
|
|
|
|
<row>
|
|
|
|
|
|
<entry>var</entry>
|
|
|
|
|
|
<entry>numeric</entry>
|
|
|
|
|
|
<entry>Oui</entry>
|
|
|
|
|
|
<entry><emphasis>n/a</emphasis></entry>
|
|
|
|
|
|
<entry>Les variables de l'op<6F>ration</entry>
|
|
|
|
|
|
</row>
|
|
|
|
|
|
<row>
|
|
|
|
|
|
<entry>assign</entry>
|
|
|
|
|
|
<entry>cha<EFBFBD>ne de caract<63>res</entry>
|
|
|
|
|
|
<entry>Non</entry>
|
|
|
|
|
|
<entry><emphasis>n/a</emphasis></entry>
|
|
|
|
|
|
<entry>Variable de template dans laquelle la sortie
|
|
|
|
|
|
sera assign<67>e</entry>
|
|
|
|
|
|
</row>
|
|
|
|
|
|
<row>
|
|
|
|
|
|
<entry>[var ...]</entry>
|
|
|
|
|
|
<entry>numeric</entry>
|
|
|
|
|
|
<entry>Oui</entry>
|
|
|
|
|
|
<entry><emphasis>n/a</emphasis></entry>
|
|
|
|
|
|
<entry>Valeurs des variables de l'op<6F>ration</entry>
|
|
|
|
|
|
</row>
|
|
|
|
|
|
</tbody>
|
|
|
|
|
|
</tgroup>
|
|
|
|
|
|
</informaltable>
|
|
|
|
|
|
<para>
|
|
|
|
|
|
math autorise les designers de templates <20> effectuer des op<6F>rations
|
|
|
|
|
|
dans le template. Toute valeur num<75>rique peut <20>tre utilis<69>e dans une
|
|
|
|
|
|
op<6F>ration, et le r<>sultat sera affich<63> <20> la place des balises
|
|
|
|
|
|
"equation". Les variables utilis<69>es dans l'op<6F>ration sont pass<73>es en
|
|
|
|
|
|
tant que param<61>tre, et peuvent <20>tre des variables de templates ou des
|
|
|
|
|
|
valeurs statiques. +, -, /, *, abs, ceil, cos,
|
|
|
|
|
|
exp, floor, log, log10, max, min, pi, pow, rand, round, sin, sqrt,
|
|
|
|
|
|
srans et tan sont tous des op<6F>rateurs valides. Voir la
|
|
|
|
|
|
documentation PHP pour plus d'informations sur ces fonctions
|
|
|
|
|
|
math<74>matiques.
|
|
|
|
|
|
</para>
|
|
|
|
|
|
<para>
|
|
|
|
|
|
Si vous sp<73>cifiez l'attribut assign, la sortie sera assign<67>e <20> la variable
|
|
|
|
|
|
donn<6E>e plut<75>t que d'<27>tre directement affich<63>e.
|
|
|
|
|
|
</para>
|
|
|
|
|
|
<note>
|
|
|
|
|
|
<title>Note technique</title>
|
|
|
|
|
|
<para>
|
|
|
|
|
|
math est une fonction co<63>teuse en terme de performances, du fait
|
|
|
|
|
|
qu'elle utilise la fonction PHP eval (). Effectuer les calculs
|
|
|
|
|
|
dans votre code PHP est beaucoup plus efficient, donc, chaque fois
|
|
|
|
|
|
que possible, effectuez vos calculs directement dans PHP et assignez
|
|
|
|
|
|
le r<>sultat au template. Evitez co<63>t que co<63>t les appels
|
|
|
|
|
|
r<>p<EFBFBD>titifs <20> la fonction math, comme on pourait le faire une
|
|
|
|
|
|
une boucle section.
|
|
|
|
|
|
</para>
|
|
|
|
|
|
</note>
|
|
|
|
|
|
<example>
|
|
|
|
|
|
<title>math</title>
|
2004-04-13 15:43:47 +00:00
|
|
|
|
<programlisting>
|
|
|
|
|
|
{* $height=4, $width=5 *}
|
|
|
|
|
|
|
|
|
|
|
|
{math equation="x + y" x=$height y=$width}
|
|
|
|
|
|
|
|
|
|
|
|
SORTIE:
|
|
|
|
|
|
|
|
|
|
|
|
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#}
|
|
|
|
|
|
|
|
|
|
|
|
SORTIE:
|
|
|
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{* vous pouvez utiliser des parenth<74>ses *}
|
|
|
|
|
|
|
|
|
|
|
|
{math equation="(( x + y ) / z )" x=2 y=10 z=2}
|
|
|
|
|
|
|
|
|
|
|
|
SORTIE:
|
|
|
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{* vous pouvez d<>finir un format sprintf pour l'affichage *}
|
|
|
|
|
|
|
|
|
|
|
|
{math equation="x + y" x=4.4444 y=5.0000 format="%.2f"}
|
|
|
|
|
|
|
|
|
|
|
|
SORTIE:
|
|
|
|
|
|
|
|
|
|
|
|
9.44</programlisting>
|
2004-05-23 15:50:53 +00:00
|
|
|
|
</example>
|
2004-04-13 15:43:47 +00:00
|
|
|
|
</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
|
2004-05-23 15:50:53 +00:00
|
|
|
|
-->
|