Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > by-pkgid > 8377d4bb25a3992aad680df2952f4b71 > files > 119

php-smarty-doc-2.6.26-1mdv2010.0.noarch.rpm

<HTML
><HEAD
><TITLE
>Variables</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
REL="HOME"
TITLE="Smarty Manual"
HREF="index.html"><LINK
REL="UP"
TITLE="Basic Syntax"
HREF="language.basic.syntax.html"><LINK
REL="PREVIOUS"
TITLE="Basic Syntax"
HREF="language.basic.syntax.html"><LINK
REL="NEXT"
TITLE="Functions"
HREF="language.syntax.functions.html"><META
HTTP-EQUIV="Content-type"
CONTENT="text/html; charset=ISO-8859-1"></HEAD
><BODY
CLASS="sect1"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>Smarty Manual</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="language.basic.syntax.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>Chapter 3. Basic Syntax</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="language.syntax.functions.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="sect1"
><H1
CLASS="sect1"
><A
NAME="language.syntax.variables"
></A
>Variables</H1
><P
>&#13;  Template variables start with the $dollar sign. They can contain numbers,
  letters and underscores, much like a
  <A
HREF="http://php.net/language.variables"
TARGET="_top"
>PHP variable</A
>.
  You can reference arrays
  by index numerically or non-numerically. Also reference
  object properties and methods.</P
><P
>&#13;  <A
HREF="language.config.variables.html"
>Config file variables</A
>
  are an exception to the $dollar syntax
  and are instead referenced with surrounding #hashmarks#, or
  via the
  <A
HREF="language.variables.smarty.html#language.variables.smarty.config"
>&#13;  <TT
CLASS="parameter"
><I
>$smarty.config</I
></TT
></A
> variable.
 </P
><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN240"
></A
><P
><B
>Example 3-2. Variables</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="programlisting"
>{$foo}        &#60;-- displaying a simple variable (non array/object)
{$foo[4]}     &#60;-- display the 5th element of a zero-indexed array
{$foo.bar}    &#60;-- display the "bar" key value of an array, similar to PHP $foo['bar']
{$foo.$bar}   &#60;-- display variable key value of an array, similar to PHP $foo[$bar]
{$foo-&#62;bar}   &#60;-- display the object property "bar"
{$foo-&#62;bar()} &#60;-- display the return value of object method "bar"
{#foo#}       &#60;-- display the config file variable "foo"
{$smarty.config.foo} &#60;-- synonym for {#foo#}
{$foo[bar]}   &#60;-- syntax only valid in a section loop, see {section}
{assign var=foo value='baa'}{$foo} &#60;--  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-&#62;bar($baz,2,$bar)} &#60;-- passing parameters
{"foo"}       &#60;-- static values are allowed

{* display the server variable "SERVER_NAME" ($_SERVER['SERVER_NAME'])*}
{$smarty.server.SERVER_NAME}</PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
><P
>Request variables such as <TT
CLASS="literal"
>$_GET</TT
>,
 <TT
CLASS="literal"
>$_SESSION</TT
>, etc are available via the
 reserved <A
HREF="language.variables.smarty.html"
>&#13; <TT
CLASS="parameter"
><I
>$smarty</I
></TT
></A
> variable.
 </P
><P
>&#13;  See also <A
HREF="language.variables.smarty.html"
>&#13;  <TT
CLASS="parameter"
><I
>$smarty</I
></TT
></A
>,
  <A
HREF="language.config.variables.html"
>config variables</A
>
  <A
HREF="language.custom.functions.html#language.function.assign"
><TT
CLASS="varname"
>{assign}</TT
></A
>
  and
  <A
HREF="api.assign.html"
><TT
CLASS="varname"
>assign()</TT
></A
>.
 </P
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="language.basic.syntax.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="language.syntax.functions.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Basic Syntax</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="language.basic.syntax.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Functions</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>