mirror of
https://github.com/smarty-php/smarty.git
synced 2025-11-06 15:21:37 +01:00
76 lines
2.6 KiB
XML
76 lines
2.6 KiB
XML
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: 1.7 Maintainer: andreas Status: ready -->
|
|
<sect1 id="language.syntax.variables">
|
|
<title>Variablen</title>
|
|
<para>
|
|
Templatevariablennamen beginnen mit einem $dollar-Zeichen. Sie
|
|
können Ziffer, Buchstaben und Unterstriche ('_') enthalten, sehr
|
|
ähnlich den <ulink
|
|
url="&url.php-manual;language.variables">Variablen in PHP</ulink>.
|
|
Numerische Arrayindizes können referenziert werden und auch
|
|
Nichtnumerische. Zugriff auf Objekteigenschaften und -methoden ist
|
|
auch möglich.
|
|
<link
|
|
linkend="language.config.variables">Konfigurationsvariablen</link>
|
|
sind einer Ausname was die Dollarzeichen-Syntax angeht. Diese werden
|
|
durch umgebende #Doppelkreuze# oder über die Varible <link
|
|
linkend="language.variables.smarty.config">$smarty.config</link>
|
|
referenziert.
|
|
</para>
|
|
<example>
|
|
<title>Variablen</title>
|
|
<programlisting>
|
|
<![CDATA[
|
|
{$foo} <-- Zeigt einfache Variable an (kein Array oder Objekt)
|
|
{$foo[4]} <-- Zeigt 5. Element von einem Array an, deren Schlussel bei 0 beginnen
|
|
{$foo.bar} <-- Zeigt das Element zum Schlüssel "bar" des Arrays an (wie PHPs $foo['bar'])
|
|
{$foo.$bar} <-- Zeigt das Element eines variablen Schlüssels an (wie PHPs $foo[$bar])
|
|
{$foo->bar} <-- Zeigt eine Eigenschaft "bar" des Objekts $foo an
|
|
{$foo->bar()} <-- Zeigt den Rückgabewert der Objectmethode "bar" an
|
|
{#foo#} <-- Zeift die Konfigurationsvariable "foo" an
|
|
{$smarty.config.foo} <-- Synonym für {#foo#}
|
|
{$foo[bar]} <-- Syntax zum zugriff auf Element in einer Section-Schleife, siehe {section}
|
|
{assign var=foo value="baa"}{$foo} <-- Gibt "baa" aus, siehe {assign}
|
|
|
|
Viele weitere Kombinationen sind erlaubt
|
|
|
|
{$foo.bar.baz}
|
|
{$foo.$bar.$baz}
|
|
{$foo[4].baz}
|
|
{$foo[4].$baz}
|
|
{$foo.bar.baz[4]}
|
|
{$foo->bar($baz,2,$bar)} <-- Parameter übergeben
|
|
{"foo"} <-- Statische (konstante) Werte sind auch erlaubt
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
<para>
|
|
Siehe auch: <link linkend="language.variables.smarty">Die reservierte
|
|
{$smarty} Variable</link> und <link
|
|
linkend="language.config.variables">Verwendung von Variablen aus
|
|
Konfigurationsdateien</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
|
|
-->
|