Blogger Information
Blog 30
fans 0
comment 0
visits 19994
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
10月31日作业,练习一下mvc的实现原理
人生就像过山车的博客
Original
562 people have browsed it

老师好, 10月31日作业,练习一下mvc的实现原理。 最近事很多,比较忙,而且由于纽约进入了冬令时,从而时差变为了13小时,以至于无法第一时间看直播了,但是还是会忙里偷闲看录播以及补写作业的,老师辛苦了,感恩感恩,虽然我进度落下来了,但是还会抽空推进,该做的作业,该交的毕设都不会少的。


index.php

$path_info = $_SERVER['PATH_INFO'];

       $path = ltrim($path_info,'/');



//解析控制器和方法

  $controller_split = explode('/',$path);


  $controller_class = ucfirst($controller_split[0]);

  $controller_method = $controller_split[1];

//加载controller文件夹下的home.php文件

  require_once __DIR__.'/controller/'.$controller_class.'.php';

  $obj = new $controller_class();

  $res = $obj-> $controller_method();

  exit($res);

home.php

class Home{


       public function index(){

           echo 'This is a MVC test';
       }

       public function homepage(){


           echo 'This is a Homepage';
       }

       public function welcome(){

           require_once __DIR__.'/../view/welcome.php';
       }
}


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