求助关于assign函数无法调用

浏览:1489 发布日期:2015/03/09 分类:求助交流
我使用的是ThinkPHP3.1.2_Core的版本,我按照网上的视频进行学习,但是为什么我写代码不支持$this->assign('name',$name)->assign('sex','man')->assign('today',$date);这种写法呢?class IndexAction extends Action {
    public function index(){
    //方式一
    $name='Vigny';     //定义一个变量
    $this->name=$name; //把变量导入到模板让name可以接收到这个值
    //方式二
    $this->name2=$name;
    $this->assign('name',$name);
    $this->assign('name',$name)->assign('sex','man')->assign('today',$date);
    $this->display(); //此处是调用Tpl目录下index文件夹内的index.html模板
    }
Call to a member function assign() on a non-object C:\php\htdocs\APP\Lib\Action\IndexAction.class.php 第 12 行.
错误位置
FILE: C:\php\htdocs\ThinkPHP\Lib\Core\Think.class.php  LINE: 275
TRACE
[15-03-09 03:54:03] C:\php\htdocs\ThinkPHP\Lib\Core\Think.class.php (275) halt(Call to a member function assign() on a non-object C:\php\htdocs\APP\Lib\Action\IndexAction.class.php 第 12 行.)
[15-03-09 03:54:03] C:\php\htdocs\ThinkPHP\Lib\Core\Think.class.php (290) Think::appError(1, Call to a member function assign() on a non-object, C:\php\htdocs\APP\Lib\Action\IndexAction.class.php, 12)
[15-03-09 03:54:03] () Think::fatalError()
错误代码显示是[code][/code]
最佳答案
评论( 相关
后面还有条评论,点击查看>>