| 991 |
lars |
1 |
# Variables
|
|
|
2 |
|
|
|
3 |
Smarty has several types of variables. The type of the
|
|
|
4 |
variable depends on what symbol it is prefixed or enclosed within.
|
|
|
5 |
|
|
|
6 |
- [Variables assigned from PHP](language-assigned-variables.md)
|
|
|
7 |
- [Variables loaded from config files](language-config-variables.md)
|
|
|
8 |
- [{$smarty} reserved variable](language-variables-smarty.md)
|
|
|
9 |
|
|
|
10 |
Variables in Smarty can be either displayed directly or used as
|
|
|
11 |
arguments for [functions](../language-basic-syntax/language-syntax-functions.md),
|
|
|
12 |
[attributes](../language-basic-syntax/language-syntax-attributes.md) and
|
|
|
13 |
[modifiers](../language-modifiers/index.md), inside conditional expressions, etc.
|
|
|
14 |
To print a variable, simply enclose it in the
|
|
|
15 |
[delimiters](../../programmers/api-variables/variable-left-delimiter.md) so that it is the only thing
|
|
|
16 |
contained between them.
|
|
|
17 |
|
|
|
18 |
```smarty
|
|
|
19 |
{$Name}
|
|
|
20 |
|
|
|
21 |
{$product.part_no} <b>{$product.description}</b>
|
|
|
22 |
|
|
|
23 |
{$Contacts[row].Phone}
|
|
|
24 |
|
|
|
25 |
<body bgcolor="{#bgcolor#}">
|
|
|
26 |
```
|
|
|
27 |
|
|
|
28 |
## Scopes
|
|
|
29 |
You can assign variables to specific [variable scopes](language-variable-scopes.md).
|
|
|
30 |
|
|
|
31 |
|
|
|
32 |
> **Note**
|
|
|
33 |
>
|
|
|
34 |
> An easy way to examine assigned Smarty variables is with the
|
|
|
35 |
> [debugging console](../chapter-debugging-console.md).
|
|
|
36 |
|