这种smarty怎么写才对? {include file='/public/www/mapdata/map_$id.inc.php'}
时间: 2024-05-26 18:11:48 浏览: 18
对于这种smarty,正确的写法是:
{include file='public/www/mapdata/map_'|cat:$id|cat:'.inc.php'}
其中,|cat: 表示字符串连接符,可以将多个字符串合并成一个字符串。在这种情况下,我们使用了 |cat: 将三个字符串合并成一个字符串,实现 include 文件的引用。
相关问题
smarty的这种语法时什么意思?{xx type=$smarty.const.xx key=value}
这种Smarty语法表示在模板中调用Smarty内置函数或变量的属性。其中,`xx`是内置函数或变量的名称,`type`是属性的名称,`$smarty.const.xx`表示调用Smarty内置常量,`key=value`表示该属性的参数。
举个例子,如果你想在模板中获取当前Smarty模板的版本号,可以使用以下代码:
```
{$smarty.version}
```
如果你想获取模板的编译目录路径,则可以使用以下语法:
```
{$smarty.config_dir}
```
其中,`version`和`config_dir`都是Smarty内置变量的属性名称。
如果你想在模板中获取PHP的`E_ALL`常量值,则可以使用以下语法:
```
{$smarty.const.E_ALL}
```
其中,`E_ALL`是PHP内置常量的名称。
需要注意的是,如果内置函数或变量的属性不存在,将会返回空值。同时,如果你想自定义属性,可以在Smarty模板中使用`$smarty`对象的`get_config_vars()`方法或`assign()`方法。
smarty输出 public $right_delimiter = "}"; 怎么设置?
你可以在Smarty初始化时设置right_delimiter属性,如下所示:
```php
require_once('path/to/Smarty/Smarty.class.php');
$smarty = new Smarty();
$smarty->right_delimiter = '}'; // 设置right_delimiter属性
```
或者在Smarty配置文件中使用以下语法:
```
{$smarty->right_delimiter = '}'}
```
这将设置Smarty的right_delimiter属性为"}"。请注意,这只能在Smarty初始化时或在Smarty配置文件中进行设置。如果你在模板中尝试设置该属性,将会导致Smarty解析错误。
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)