1 环境搭建
http://imcn.me/html/y2012/12401.html
2 thinkphp 手册
http://document.thinkphp.cn/manual_3_2.html
从前端访问到thinkphp的过程
访问路径 http://X.X.X.X/oidbhelp/app/index.php/Home/Index/index.html
第一步:找到\oidbhelp\app\Application\Home\Controller 下 类IndexController.class.php 中类 IndexController 中的 index 方法
第二步:index 方法处理完后,最后的$this->show() 会找到oidbhelp\app\Application\Home\View\Index 下的 index.html,进行叶面展示
总结: thinkphp 会将url路径转换为对Controller 下对应文件的类的函数的调用,
函数中的show操作会调用oidbhelp\app\Application\Home\View\Index 下的静态页面用于展示。
><?php
namespace Home\Controller;
use Think\Controller;
include 'public/login.php';
class IndexController extends Controller {
public function index(){
//get the all question
$question = D("Question");
$ret = $question->field('qid,pid,content')->order('qid')->select();
$arraylen = count($ret);
$ret = json_encode($ret);
$this->assign('items', $ret);
$this->show();
}
public function managerQuestion() {
$keyword= D('Keyword');
$ret = $keyword->field('content')->select();
$ret = json_encode($ret);
$this->assign('kitems',$ret);
$question = D("Question");
$ret = $question->field('qid,pid,content')->order('qid')->select();
$ret = json_encode($ret);
$this->assign('qitems', $ret);
$this->show();
}
public function managerAnswer(){
$keyword= D('Keyword');
$ret = $keyword->field('content')->select();
$ret = json_encode($ret);
$this->assign('kitems',$ret);
$question = D("Question");
$ret = $question->field('qid,pid,content')->order('qid')->select();
$ret = json_encode($ret);
$this->assign('qitems', $ret);
$this->show();
}
}
?>
index 方法处理完后,最后的$this->show() 会找到