2004-04-13 15:43:47 +00:00
|
|
|
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
|
|
|
|
<!-- $Revision$ -->
|
2004-07-04 09:51:24 +00:00
|
|
|
|
<!-- EN-Revision: 1.1 Maintainer: gerald Status: ready -->
|
2004-04-20 11:20:27 +00:00
|
|
|
|
<sect1 id="language.assigned.variables">
|
|
|
|
|
|
<title>Variables assign<67>es depuis PHP</title>
|
|
|
|
|
|
<para>
|
2004-05-23 15:50:53 +00:00
|
|
|
|
Pour utiliser une variables assign<67>es depuis PHP, il
|
|
|
|
|
|
faut la pr<70>fixer par le symbole dollar <literal>$</literal>.
|
2004-04-20 11:20:27 +00:00
|
|
|
|
Les variables asign<67>es depuis un template gr<67>ce <20> la fonction
|
2004-05-23 15:50:53 +00:00
|
|
|
|
<link linkend="language.function.assign">assign</link> sont
|
|
|
|
|
|
manipul<75>es de la m<>me fa<66>on.
|
|
|
|
|
|
</para>
|
|
|
|
|
|
<example>
|
|
|
|
|
|
<title>Variables assign<67>es</title>
|
|
|
|
|
|
<programlisting>
|
2004-04-20 11:20:27 +00:00
|
|
|
|
<![CDATA[
|
2004-04-13 15:43:47 +00:00
|
|
|
|
Bienvenue {$prenom}, heureux de voir que tu es arriv<69> ici.
|
2004-04-20 11:20:27 +00:00
|
|
|
|
<p>
|
2004-04-13 15:43:47 +00:00
|
|
|
|
La derni<6E>re connexion remonte au {$dateConnexionPrecedente}.
|
2004-04-20 11:20:27 +00:00
|
|
|
|
]]>
|
2004-05-23 15:50:53 +00:00
|
|
|
|
</programlisting>
|
|
|
|
|
|
<para>
|
|
|
|
|
|
Cela va afficher:
|
|
|
|
|
|
</para>
|
|
|
|
|
|
<screen>
|
2004-04-20 11:20:27 +00:00
|
|
|
|
<![CDATA[
|
|
|
|
|
|
Bienvenue Doug, heureux de voir que tu es arriv<69> ici.
|
|
|
|
|
|
<p>
|
|
|
|
|
|
La derni<6E>re connexion remonte au 11 janvier 2001.
|
|
|
|
|
|
]]>
|
2004-05-23 15:50:53 +00:00
|
|
|
|
</screen>
|
|
|
|
|
|
</example>
|
|
|
|
|
|
|
|
|
|
|
|
<sect2 id="language.variables.assoc.arrays">
|
|
|
|
|
|
<title>Tableaux associatifs</title>
|
|
|
|
|
|
<para>
|
|
|
|
|
|
Vous pouvez <20>galement utiliser des variables sous forme de tableaux
|
|
|
|
|
|
associatifs assign<67>es depuis PHP en en sp<73>cifiant la clef,
|
|
|
|
|
|
apr<70>s le symbole '.' (point).
|
|
|
|
|
|
</para>
|
|
|
|
|
|
<example>
|
|
|
|
|
|
<title>Acc<EFBFBD>der aux variables de tableaux associatifs</title>
|
|
|
|
|
|
<programlisting role="php">
|
2004-04-20 11:20:27 +00:00
|
|
|
|
<![CDATA[
|
|
|
|
|
|
<?php
|
2004-04-13 15:43:47 +00:00
|
|
|
|
|
|
|
|
|
|
$smarty = new Smarty;
|
2004-04-20 11:20:27 +00:00
|
|
|
|
$smarty->assign('Contacts',
|
2004-04-13 15:43:47 +00:00
|
|
|
|
array('fax' => '555-222-9876',
|
|
|
|
|
|
'email' => 'zaphod@slartibartfast.com',
|
|
|
|
|
|
'phone' => array('home' => '555-444-3333',
|
|
|
|
|
|
'cell' => '555-111-1234')));
|
2004-04-20 11:20:27 +00:00
|
|
|
|
$smarty->display('index.tpl');
|
|
|
|
|
|
?>
|
|
|
|
|
|
]]>
|
2004-05-23 15:50:53 +00:00
|
|
|
|
</programlisting>
|
|
|
|
|
|
<para>
|
|
|
|
|
|
o<> index.tpl est :
|
|
|
|
|
|
</para>
|
|
|
|
|
|
<programlisting>
|
2004-04-20 11:20:27 +00:00
|
|
|
|
<![CDATA[
|
|
|
|
|
|
{$Contacts.fax}<br />
|
|
|
|
|
|
{$Contacts.email}<br />
|
|
|
|
|
|
{* vous pouvez afficher des tableaux de tableaux *}
|
|
|
|
|
|
{$Contacts.phone.home}<br />
|
|
|
|
|
|
{$Contacts.phone.cell}<br />
|
|
|
|
|
|
]]>
|
2004-05-23 15:50:53 +00:00
|
|
|
|
</programlisting>
|
|
|
|
|
|
<para>
|
2004-07-04 09:51:24 +00:00
|
|
|
|
Ce qui donne en sortie :
|
2004-05-23 15:50:53 +00:00
|
|
|
|
</para>
|
|
|
|
|
|
<screen>
|
2004-04-20 11:20:27 +00:00
|
|
|
|
<![CDATA[
|
|
|
|
|
|
555-222-9876<br />
|
|
|
|
|
|
zaphod@slartibartfast.com<br />
|
|
|
|
|
|
555-444-3333<br />
|
|
|
|
|
|
555-111-1234<br />
|
|
|
|
|
|
]]>
|
2004-05-23 15:50:53 +00:00
|
|
|
|
</screen>
|
|
|
|
|
|
</example>
|
|
|
|
|
|
</sect2>
|
|
|
|
|
|
|
|
|
|
|
|
<sect2 id="language.variables.array.indexes">
|
|
|
|
|
|
<title>Tableaux index<65>s</title>
|
|
|
|
|
|
<para>
|
|
|
|
|
|
Vous pouvez utiliser des tableaux index<65>s de la m<>me fa<66>on
|
|
|
|
|
|
que vous le faites en PHP.
|
|
|
|
|
|
</para>
|
|
|
|
|
|
<example>
|
|
|
|
|
|
<title>Acc<EFBFBD>s aux tableaux gr<67>ce <20> l'index</title>
|
2004-07-04 09:51:24 +00:00
|
|
|
|
<programlisting role="php">
|
|
|
|
|
|
<![CDATA[
|
|
|
|
|
|
<?php
|
2004-04-13 15:43:47 +00:00
|
|
|
|
$smarty = new Smarty;
|
2004-07-04 09:51:24 +00:00
|
|
|
|
$smarty->assign('Contacts',
|
2004-04-13 15:43:47 +00:00
|
|
|
|
array('555-222-9876',
|
|
|
|
|
|
'zaphod@slartibartfast.com',
|
|
|
|
|
|
array('555-444-3333',
|
|
|
|
|
|
'555-111-1234')));
|
2004-07-04 09:51:24 +00:00
|
|
|
|
$smarty->display('index.tpl');
|
|
|
|
|
|
?>
|
|
|
|
|
|
]]>
|
|
|
|
|
|
</programlisting>
|
|
|
|
|
|
<para>
|
|
|
|
|
|
Ou index.tpl est :
|
|
|
|
|
|
</para>
|
|
|
|
|
|
<programlisting>
|
|
|
|
|
|
<![CDATA[
|
|
|
|
|
|
{$Contacts[0]}<br />
|
|
|
|
|
|
{$Contacts[1]}<br />
|
|
|
|
|
|
{* Vous pouvez <20>galement afficher des tableaux *}
|
|
|
|
|
|
{$Contacts[2][0]}<br />
|
|
|
|
|
|
{$Contacts[2][1]}<br />
|
|
|
|
|
|
]]>
|
|
|
|
|
|
</programlisting>
|
|
|
|
|
|
<para>
|
|
|
|
|
|
ce qui donne en sortie :
|
|
|
|
|
|
</para>
|
|
|
|
|
|
<screen>
|
|
|
|
|
|
<![CDATA[
|
|
|
|
|
|
555-222-9876<br />
|
|
|
|
|
|
zaphod@slartibartfast.com<br />
|
|
|
|
|
|
555-444-3333<br />
|
|
|
|
|
|
555-111-1234<br />
|
|
|
|
|
|
]]>
|
|
|
|
|
|
</screen>
|
2004-05-23 15:50:53 +00:00
|
|
|
|
</example>
|
|
|
|
|
|
</sect2>
|
|
|
|
|
|
<sect2 id="language.variables.objects">
|
|
|
|
|
|
<title>Objets</title>
|
|
|
|
|
|
<para>
|
|
|
|
|
|
Les attributs des objets assign<67>s depuis PHP peuvent <20>tre utilis<69>es en
|
|
|
|
|
|
en sp<73>cifiant le nom apr<70>s le symbole '->'.
|
|
|
|
|
|
</para>
|
|
|
|
|
|
<example>
|
|
|
|
|
|
<title>acc<EFBFBD>der aux attributs des objets</title>
|
2004-04-13 15:43:47 +00:00
|
|
|
|
<programlisting>
|
2004-07-04 09:51:24 +00:00
|
|
|
|
<![CDATA[
|
|
|
|
|
|
nom: {$person->name}<br />
|
|
|
|
|
|
email: {$person->email}<br />
|
|
|
|
|
|
]]>
|
|
|
|
|
|
</programlisting>
|
|
|
|
|
|
<para>
|
|
|
|
|
|
Ce qui donne en sortie :
|
|
|
|
|
|
</para>
|
|
|
|
|
|
<screen>
|
|
|
|
|
|
<![CDATA[
|
|
|
|
|
|
nom: Zaphod Beeblebrox<br />
|
|
|
|
|
|
email: zaphod@slartibartfast.com<br />
|
|
|
|
|
|
]]>
|
|
|
|
|
|
</screen>
|
2004-05-23 15:50:53 +00:00
|
|
|
|
</example>
|
|
|
|
|
|
</sect2>
|
|
|
|
|
|
</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
|
|
|
|
|
|
-->
|