php之smarty分配变量
2015-12-21 21:51
686 查看
smarty2.php
demo2.tpl
访问地址:http://127.0.0.1/smarty2.php?name=hahahahaha
<?php //require('Smarty/Smarty.class.php'); require './smarty.inc.php'; global $_smarty; $_title = 'Smarty模板引擎'; $_smarty->assign('title', $_title); $_array = array('aaa', 'bbbb', 'ccc', 'dddd'); $_array2 = array('haha'=>'aaa', 'hehe'=>'bbbb', 'lala'=>'ccc', 'xixi'=>'dddd'); $_array3 = array( array('haha', 'ssss'), array('lala','ssdvs'), array('ewef','wefwa') ); $_array4 = array( 'aa'=>array('haha', 'ssss'), 'bb'=>array('lala','ssdvs'), 'cc'=>array('ewef','wefwa') ); class People { public $_name = 'nini'; public function _run() { return 'running....'; } }; $_smarty->assign('array', $_array); $_smarty->assign('array2', $_array2); $_smarty->assign('array3', $_array3); $_smarty->assign('array4', $_array4); $_smarty->assign('people', new People()); $_smarty->display('demo2.tpl'); //phpinfo(); ?>
demo2.tpl
{config_load file='webconfig.config'} <html> <head><title>{$title}</title></head> <body> <p> hi,{$name} Welcome to website!!! <br> {$array[2]} <br> {$array2.hehe} <br> {$array3[2][0]} <br> {$array4.bb[1]} <br> {$people->_name} {$people->_run()} <br> {$smarty.config.webname} {#weburl#} <br> {$smarty.get.name} </p> </body> </html>
访问地址:http://127.0.0.1/smarty2.php?name=hahahahaha
相关文章推荐
- php 类的构造方法 __construct
- PHP学习练手(三)
- PHP中获取文件扩展名的N种方法
- Zend Studio/Eclipse更改背景风格主题
- Windows Server 2008 阿里云服务器(ECS)配置FTP传输
- ThinkPHP3.2版本—视图与模板
- php 过滤特殊字符 如 ◆ )- : 、 、!! / 等
- ThinkPHP3.2实现简单的数据分页
- 安装vsftpd
- smarty中调用php内置函数
- ftp工具-filezilla搭建(windows环境下)
- 802.1D,STP感悟
- php分享十四:php接口编写
- 微软Visual Studio "14" CTP 2 公布
- PHP 利用curl发送指定远程IP请求
- 一次php gd库引发的问题
- php write excel
- PHP商品秒杀计时实现(解决大流量方案)
- 第四十九天:php-7.0编译模块的出错
- PHP(四)运算符、表达式和语句