There are bugs in MVC with PHP (1). The biggest problem is the log system. After completing this introduction, I will package all the corrected program source codes
and I will not make any changes here for the time being. .
Let’s first take a look at how to create a controller instance in application.class.php:
PHP code:---------------------- -------------------------------------------------- --------
/**
* Execution function
*
* The only external interface of this type
**/
public function run()
{
$this->parsePath();
$this-> ;checkSecurity($this->module, $this->action);
1. $controller = new $this->controllerClassName();
2. $controller->{$this- >action}();
$this->writeLog($this->module, $this->action);
}
---------- -------------------------------------------------- ------------------
The Application class is the only function that can be called after the instance. It analyzes the required Controller class based on the user's URL request. name, then instantiate this class (marked 1 above), and then call the action name obtained from the URL (marked 2 above),
Here is a simple example:
URL: http:/ /localhost/?module=news&action=showList
Application returns to controllerClassName=news, action=showList by parsing this URL, and then it will process the file name of this controller class (in Application->getControllerFile() ), then instantiate the News
controller class (marked 1), and then call its action showList (marked 2).
Let’s take a look at the content in newsController.php:
== ================================================== =========
PHP code:---------------------------------- ------------------------------------------------
< ?php
/**
* FileName: newsController.php
* Introduce: News Control Class
*
* @author: Senior Brother
* @Email: teacherli@163.com
* @version $ Id$
* @copyright 2004-10-26
**/
include_once ("./controller/comm/controller.class.php");
include_once ("./model/news/newsModel.php") ;
class NewsController extends Controller