mirror of
https://github.com/smarty-php/smarty.git
synced 2025-11-05 23:01:37 +01:00
86 lines
2.8 KiB
XML
86 lines
2.8 KiB
XML
|
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
|||
|
|
<!-- $Revision$ -->
|
|||
|
|
<!-- EN-Revision: 1.14 Maintainer: fernandoc Status: ready -->
|
|||
|
|
|
|||
|
|
<sect1 id="language.syntax.variables">
|
|||
|
|
<title>Variables</title>
|
|||
|
|
<para>
|
|||
|
|
Vaiaveis do template come<6D>am com o sinal de $dollar. Elas podem conter n<>meros,
|
|||
|
|
letras e sublinhados, parecido com
|
|||
|
|
<ulink url="&url.php-manual;language.variables">vari<EFBFBD>vel PHP</ulink>.
|
|||
|
|
Voc<6F> pode referenciar arrays
|
|||
|
|
pelo <20>ndice n<>mero ou n<>o num<75>rico. Tamb<6D>m pode
|
|||
|
|
referenciar propriedades e metodos de objetos.</para>
|
|||
|
|
<para>
|
|||
|
|
<link linkend="language.config.variables">Vari<EFBFBD>veis do arquivo de configura<72><61>o</link>
|
|||
|
|
s<>o excess<73>es a sintaxe de $dollar
|
|||
|
|
e s<>o ao inv<6E>s referenciadas com #cancelas#, ou
|
|||
|
|
via a vari<72>vel
|
|||
|
|
<link linkend="language.variables.smarty.config">$smarty.config</link>.
|
|||
|
|
</para>
|
|||
|
|
<example>
|
|||
|
|
<title>Vari<EFBFBD>veis</title>
|
|||
|
|
<programlisting>
|
|||
|
|
<![CDATA[
|
|||
|
|
{$foo} <-- mostrando uma vari<EFBFBD>vel simples (n<EFBFBD>o array/objeto)
|
|||
|
|
{$foo[4]} <-- mostrando o quito elemento de uma array que come<EFBFBD>a em zero
|
|||
|
|
{$foo.bar} <-- mostrando o valor da chave "bar" da array, similar ao PHP $foo['bar']
|
|||
|
|
{$foo.$bar} <-- display variable key value of an array, similar to PHP $foo[$bar]
|
|||
|
|
{$foo->bar} <-- display the object property "bar"
|
|||
|
|
{$foo->bar()} <-- display the return value of object method "bar"
|
|||
|
|
{#foo#} <-- display the config file variable "foo"
|
|||
|
|
{$smarty.config.foo} <-- synonym for {#foo#}
|
|||
|
|
{$foo[bar]} <-- syntax only valid in a section loop, see {section}
|
|||
|
|
{assign var=foo value='baa'}{$foo} <-- displays "baa", see {assign}
|
|||
|
|
|
|||
|
|
Many other combinations are allowed
|
|||
|
|
|
|||
|
|
{$foo.bar.baz}
|
|||
|
|
{$foo.$bar.$baz}
|
|||
|
|
{$foo[4].baz}
|
|||
|
|
{$foo[4].$baz}
|
|||
|
|
{$foo.bar.baz[4]}
|
|||
|
|
{$foo->bar($baz,2,$bar)} <-- passing parameters
|
|||
|
|
{"foo"} <-- static values are allowed
|
|||
|
|
|
|||
|
|
{* display the server variable "SERVER_NAME" ($_SERVER['SERVER_NAME'])*}
|
|||
|
|
{$smarty.server.SERVER_NAME}
|
|||
|
|
]]>
|
|||
|
|
</programlisting>
|
|||
|
|
</example>
|
|||
|
|
|
|||
|
|
<para>Vari<EFBFBD>veis de requisi<73><69>o como $_GET, $_SESSION etc est<73>o dispon<6F>veis atrav<61>s
|
|||
|
|
da vari<72>vel reservada <emphasis role="bold">
|
|||
|
|
<link linkend="language.variables.smarty">$smarty</link></emphasis>.
|
|||
|
|
</para>
|
|||
|
|
|
|||
|
|
<para>
|
|||
|
|
Veja tamb<6D>m <link linkend="language.variables.smarty">Vari<EFBFBD>veis reservadas do $smarty</link>,
|
|||
|
|
<link linkend="language.config.variables">Vari<EFBFBD>veis da Configura<72><61>o</link>
|
|||
|
|
<link linkend="language.function.assign">{assign}</link>
|
|||
|
|
e
|
|||
|
|
<link linkend="api.assign">assign()</link>.
|
|||
|
|
</para>
|
|||
|
|
</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
|
|||
|
|
-->
|