接下来按照如下步骤:
<?php
//定义项目名称
define('APP_NAME','home');
//定义项目路径
define('APP_PATH','./home/');
//开启调试模式
define('APP_DEBUG',true);
//加载框架入口文件
require'./ThinkPHP/ThinkPHP.php';
?>
接下来配置路由器,目前用到的目录是Lib下面的Action目录,存放类似于Java的Struts框架的Action。还有模板目录Tpl,下面存放的都是html文件,配合模板引擎用于前端显示。(在搭建环境的时候,有smarty模板引擎等开发经验和MVC框架的使用经验,可能更有助于理解)。然后在Action文件夹下面,新建一个AccountAction.class.php。命名规则为:模块名+class.php
<?php
class AccountAction extends Action
{
public function login(){
$this->display('login');
}
}
在Tpl目录下面放文件login.html用于显示。访问localhost/index.php/hlm/Account/login会跳转到login.html页面
更多学习内容可关注猿团云教育:http://www.yuantuan.com/index/index/edu
最佳答案