>  기사  >  백엔드 개발  >  thinkphp模板使用有关问题

thinkphp模板使用有关问题

WBOY
WBOY원래의
2016-06-13 13:52:36726검색

thinkphp模板使用问题
在thinkphp里面结合使用smarty模板,都已经配置好了,在IndexAction.class.php文件里面使用$this->display("login")没有问题,但是另外一个文件DefaultAction.class.php文件里面同样使用,则出现以下问题:
Fatal error: Call to a member function display() on a non-object in E:\php\AppServ\www\DLP\ThinkPHP\Lib\Think\Core\Action.class.php on line 103

其中Action.class.php那边的代码是:

  protected function display($templateFile='',$charset='',$contentType='text/html')
  {echo $templateFile;
  if(false === $templateFile) {
  $this->showTrace();
  }else{
  $this->view->display($templateFile,$charset,$contentType);
  }
  }

有没有出现过同样问题的大哥,给个帮助...

------解决方案--------------------
我也出现过,因为Action用了构造函数
function __construct()
{
//content
}

在TP中要用

function __construct()
{
parent::__construct;
}

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.