1.在成员方法中使用类成员:
calss ren {
private $birthday = '1990-1-1';
public function say_birthday(){
echo '我的生日是'.$this->birthday;
}
}
2.视图赋值:模板赋值
//assign方法
namespace ..
class Index entends Controller
{
public function index()
{
//模板变量赋值
$this -> assign('name','ThinkPHP');
$this -> assign('email','thinkphp@akang');
//批量赋值
$this->assign([
'name'=> 'Thinkphp',
'email'=> 'nihao'
]);
//模板输出
return $this -> fetch('index');
}
}
//fetch方法
class Index entends Controller{
public function index(){
return $this -> fetch('index',[
'name'=>'thinkphp',
'email'=>'thinkphp'
]);
}
}
3.