summaryrefslogtreecommitdiff
path: root/docs/api/variables/static-class-methods.md
blob: fd3fea4c841219b16ed934112e8ab2c6704b03bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# Static Classes

You can directly access static classes. The syntax is roughly the same as in
PHP.

> **Note**
>
> Direct access to PHP classes is not recommended. This ties the
> underlying application code structure directly to the presentation,
> and also complicates template syntax. It is recommended to register
> plugins which insulate templates from PHP classes/objects. Use at your
> own discretion.

## Examples

**class constant BAR**
```smarty
{assign var=foo value=myclass::BAR}
```

**method result**
```smarty
{assign var=foo value=myclass::method()} 
```

**method chaining**
```smarty
{assign var=foo value=myclass::method1()->method2}
```

**property bar of class myclass**
```smarty
{assign var=foo value=myclass::$bar} 
```

**using Smarty variable bar as class name**
```smarty
{assign var=foo value=$bar::method}
```