• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

php之smarty分配变量

php 搞代码 4年前 (2022-01-23) 15次浏览 已收录 0个评论

smarty2.php

<?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'}  {$title}  <bod6本文来源gao@dai!ma.com搞$代^码!网7
搞gaodaima代码

y>

hi,{$name} Welcome to website!!!
{$array[2]}
{$array2.hehe}
{$array3[2][0]}
{$array4.bb[1]}
{$people->_name} {$people->_run()}
{$smarty.config.webname} {#weburl#}
{$smarty.get.name}

访问地址:http://127.0.0.1/smarty2.php?name=hahahahaha

以上就介绍了php之smarty分配变量,包括了require方面的内容,希望对PHP教程有兴趣的朋友有所帮助。


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:php之smarty分配变量
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址