Home >Backend Development >PHP Tutorial >问个应该是非常简单的thinkphp问题

问个应该是非常简单的thinkphp问题

WBOY
WBOYOriginal
2016-06-23 13:28:10806browse

thinkphp版本3.2.3
控制器代码

<?phpnamespace Home\Controller;use Think\Controller;class IndexController extends Controller {    public function index(){		$name = 'ThinkPHP';		this->assign('name2',$name);  //问题1: 这里会报错 syntax error, unexpected T_OBJECT_OPERATOR		this->display();    }}

VIEW目录中的index.html代码
 <html> <head></head> <body> <p>this is view</p> {$name2} <? //echo $name2;    ?> </body> <html>


如上方代码,设置参数时报错了,请高手指点


回复讨论(解决方案)

我是参照了thinkphp3.1的写法,但是在3.2中,好像这样写是不对的,
this->assign  和 this->display 这两个写法都会报错

请把$还给this

this 应为  $this

 我又二了。。。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn