这次给大家带来thinkPHP控制器变量在模板内显示步骤详解,thinkPHP控制器变量在模板内显示的注意事项有哪些,下面就是实战案例,一起来看一下。
控制器中变量public function register() {
$type = I("param.type");//1.学生注册 2.教师注册 3.其他注册
$this -> assign("type", $type);
//q全部部门
$depart1 = M("Depart") -> where("status=1 and fid=0") -> order("id asc") -> select();
$this -> assign("depart1", $depart1);
$this -> display();
}
模板中引用位置一:php代码中,直接用$i;
echo $i;
模板中引用位置二:模板中直接应用{$i}或者 class="{$unlogined}"注意:1.非相关人员,严禁注册。{$i}
$logined = is_array($_SESSION['userInfo']) ? "" : "hide-p";
$unlogined = $logined == "hide-p" ? "" : "hide-p";
模板中引用位置三:模板标签中用,如condition中用,不加{}。
一级部门: *
-----请选择一级部门-----
{$vo.name}
二级部门: *
-----请先选择一级部门-----
三级部门: *
-----请先选择二级部门-----
相信看了本文案例你已经掌握了方法,更多精彩请关注php中文网其它相关文章!
推荐阅读: