Ec (2); this is an article about how to use php to implement MVC mode development. Technical Articles on the MVC mode can be found everywhere on the Internet, so this document will not describe the advantages and disadvantages of this mode (in fact, I am not clear about it). I will explain his php technology implementation. In the future series of articles, we will also focus on technology. 1. implement a unified website portal (call the Controler Layer Method in MVC, that is, the control layer). You may often see this path on the Internet (www. aaa. script ec (2); script
This document describes how to use php to implement MVC mode development. Technical Articles on the MVC mode can be found everywhere on the Internet, so this document will not describe the advantages and disadvantages of this mode (in fact, I am not clear about it). I will explain his php technology implementation. In the future series of articles, we will also focus on technology.
1. implement a unified website portal (call the Controler Layer Method in MVC, that is, the control layer)
You may often see this path on the Internet (http://www.aaa.com/aaa/bbb/aaa? Id = 5), confusing. There are several possibilities for implementing such a website:
1. Hiding the file extension has different opinions on the advantages of this approach, but I personally think it is unnecessary;
2. Use website redirection rules to implement virtual paths;
3. Implement Virtual paths by force file resolution.
23rd methods can be used to achieve unified website interfaces, reasonably integrate websites, and better reflect the security and architecture of websites. Most websites using these two methods use the "MVC" pattern to construct
Built and implemented.
The following is an example.
The access path is as follows:
.../Test/******/Bad .../Test/******/Good (The "*******" can be replaced with any string. "..." Is your web path)
|
The directory structure of the file is as follows:
| --. Htaccess | -- Test | -- Application. php | -- Controler/GoodControler. php | -- Controler/BadControler. php
Note that the file ". htaccess" cannot be directly created in windows. It can be created in command line mode.
|
File 0 :(. htaccess) (this file is used to change the apache configuration method)
Forcetype application/x-httpd-php |
File 1: (test. php)
/*------------------------------------- * Test. php * * Files used as the portal for your website * Used for initialization and entry * Call and execute the call of Controler * -------------------------------------*/ Require "Application. php "; $ Aa = new Application (); $ Aa-> parse (); $ Aa-> go ();
?>
|
File 2: (GoodControler. php)