Blogger Information
Blog 38
fans 0
comment 0
visits 22642
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
路由映射演示
一个好人
Original
1154 people have browsed it

引入控制器:

  1. require __DIR__.'/app/controller/User.php';

获取路径资源:

  1. $pathinfo = array_values(array_filter(explode('/',$_SERVER['REQUEST_URI'])));
  2. 经过分割、过滤、归零处理

取值分别赋给应用名、控制器和方法:

  1. $appName = array_shift($pathinfo);
  2. $controller = ucfirst(array_shift($pathinfo));
  3. $action = array_shift($pathinfo);

获取参数:

  1. // $params = [$_GET['id'],$_GET['name']];
  2. $params = [$_GET['phone']];

创建控制器:

  1. $u = new $controller;

输出内容:

  1. echo call_user_func_array([$u,$action],$params);

控制器内容:

  1. public function index($id, $name){
  2. // $this->view->render('视图文件',[模板参数])
  3. return '用户id:'.$id.';姓名:'.$name;
  4. }
  5. public function checkTicket($phone){
  6. // 根据参数查询表单,C-M-C的过程
  7. // $res = select
  8. // $this->view->render('视图文件',[$res])
  9. return '用户手机:'.$phone;
  10. }

总结:

获取数据的过程在模型中完成,控制器调用模型的方法从而获得数据,具体如何操作还没实施过。

Correcting teacher:欧阳克欧阳克

Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post