学习ThinkPHP3.2.2(二):第二个入门例子

    这个例子不涉及数据库操做。在控制器中设置变量值,经过模板显示该变量值。php

 

    一、以第一个例子的文件夹及文件为基础。html

 

    二、修改D:\wamp\www\MyWeb\Application\Home\Controller\IndexController.class.php:数据库

<?phpthis

namespace Home\Controller;spa

use Think\Controller;htm

class IndexController extends Controller {it

    public function index(){io

 

$name = 'ThinkPHP';function

$this->assign('name',$name);模板

$this->display();

 

 

}

}

 

    三、修改D:\wamp\www\MyWeb\Application\Home\View\Index\index.html:

<html>

 <head>

   <title>Select Data</title>

 </head>

 <body>

 

hello, {$name}!

 

 </body>

</html> 

 

    四、浏览网址:http://localhost/MyWeb/index.php/Home/Index/index.html

显示内容:

hello, ThinkPHP! 

相关文章
相关标签/搜索