2004-12-26 20:17:41 +00:00
|
|
|
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
|
|
|
|
<!-- $Revision$ -->
|
2005-05-24 20:46:11 +00:00
|
|
|
|
<!-- EN-Revision: 1.6 Maintainer: yannick Status: ready -->
|
2004-12-26 20:17:41 +00:00
|
|
|
|
<sect1 id="language.syntax.variables">
|
|
|
|
|
|
<title>Variables</title>
|
|
|
|
|
|
<para>
|
|
|
|
|
|
Les variables de template commence par un signe dollar (<literal>$</literal>).
|
|
|
|
|
|
Elles peuvent contenir des nombres, des lettres et des underscores, tout
|
2005-05-24 20:46:11 +00:00
|
|
|
|
comme une <ulink url="&url.php-manual;language.variables">variable PHP</ulink>. Vous pouvez r<>f<EFBFBD>rencer des tableaux index<65>s
|
2004-12-26 20:17:41 +00:00
|
|
|
|
num<75>riquement ou non. Vous pouvez aussi r<>f<EFBFBD>rencer des propri<72>t<EFBFBD>s d'objet
|
2005-05-24 20:46:11 +00:00
|
|
|
|
ainsi que des m<>thodes. Les <link linkend="language.config.variables">variables des fichiers de
|
|
|
|
|
|
configuration</link> sont
|
2004-12-26 20:17:41 +00:00
|
|
|
|
une exception <20> la synthaxe utilisant un signe dollar. Elles peuvent <20>tre
|
|
|
|
|
|
r<>f<EFBFBD>renc<6E>es en les entourant du signe di<64>se (<literal>#</literal>) ou
|
2005-05-24 20:46:11 +00:00
|
|
|
|
avec la variable sp<73>ciale <link linkend="language.variables.smarty.config">$smarty.config</link>.
|
2004-12-26 20:17:41 +00:00
|
|
|
|
</para>
|
|
|
|
|
|
<example>
|
|
|
|
|
|
<title>Variables</title>
|
|
|
|
|
|
<programlisting>
|
|
|
|
|
|
<![CDATA[
|
|
|
|
|
|
{$foo} <-- affiche une variable simple (qui n'estpas un tableau ou un objet)
|
|
|
|
|
|
{$foo[4]} <-- affiche le 5<EFBFBD>me <EFBFBD>l<EFBFBD>ment d'un tableau index<EFBFBD>
|
|
|
|
|
|
{$foo.bar} <-- affiche la cl<EFBFBD> "bar" d'un tableau, identique <EFBFBD> $foo['bar'] en PHP
|
|
|
|
|
|
{$foo.$bar} <-- affiche la valeur de la cl<EFBFBD> d'un tableau, identique <EFBFBD> $foo[$bar] en PHP
|
|
|
|
|
|
{$foo->bar} <-- affiche la propri<EFBFBD>t<EFBFBD> "bar" de l'objet
|
|
|
|
|
|
{$foo->bar()} <-- affiche la valeur retourn<EFBFBD>e de la m<EFBFBD>thode "bar" de l'objet
|
|
|
|
|
|
{#foo#} <-- affiche la variable du fichier de configuration "foo"
|
|
|
|
|
|
{$smarty.config.foo} <-- synonyme pour {#foo#}
|
|
|
|
|
|
{$foo[bar]} <-- synthaxe uniquement valide dans une section de boucle, voir {section}
|
2005-05-24 20:46:11 +00:00
|
|
|
|
{assign var=foo value="baa"}{$foo} <-- affiche "baa", voir {assign}
|
2004-12-26 20:17:41 +00:00
|
|
|
|
|
|
|
|
|
|
Plusieurs autres combinaisons sont autoris<69>es
|
|
|
|
|
|
|
|
|
|
|
|
{$foo.bar.baz}
|
|
|
|
|
|
{$foo.$bar.$baz}
|
|
|
|
|
|
{$foo[4].baz}
|
|
|
|
|
|
{$foo[4].$baz}
|
|
|
|
|
|
{$foo.bar.baz[4]}
|
|
|
|
|
|
{$foo->bar($baz,2,$bar)} <-- passage de param<EFBFBD>tres
|
|
|
|
|
|
{"foo"} <-- les valeurs statiques sont autoris<EFBFBD>es
|
|
|
|
|
|
]]>
|
|
|
|
|
|
</programlisting>
|
|
|
|
|
|
</example>
|
2005-05-10 21:15:40 +00:00
|
|
|
|
<para>
|
|
|
|
|
|
Voir aussi
|
|
|
|
|
|
<link linkend="language.variables.smarty">les variables r<>serv<72>es $smarty</link> et
|
|
|
|
|
|
<link linkend="language.config.variables">les variables de configuration</link>.
|
|
|
|
|
|
</para>
|
2004-12-26 20:17:41 +00:00
|
|
|
|
</sect1>
|
2005-05-24 20:46:11 +00:00
|
|
|
|
|
2004-12-26 20:17:41 +00:00
|
|
|
|
<!-- 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
|
2005-05-24 20:46:11 +00:00
|
|
|
|
-->
|