This is a file that describes how to use PHP to implement MVC pattern development. Technical articles about the MVC pattern are available on the Web, so this document will no longer describe the pros and cons of this model (actually I'm not sure), and I'll talk about his PHP technology implementation. And in the later series of articles are mainly speaking technology.
First, the implementation of a unified Web site portal (in MVC call the Controler layer method, that is, the control layer)
You may often see such a path on the Internet (http://www.aaa.com/aaa/bbb/aaa?id=5), it is puzzling that such a site can be implemented in several ways:
1, hidden file extension, the benefits of this approach, there are divergent views, but personally feel that there is no need;
2, the use of the Web site redirection rules to achieve virtual path;
3, the way to enforce file resolution, the implementation of virtual path.
Using the 23rd method can achieve the unified interface of the website, reasonable integration of the site, better reflect the security and structure of the site, in both ways, most of the sites are using "MVC" mode structure
Built and realized.
Here is an example
The access path is as follows:
.../test/*******/bad
.../test/*******/good
(the "Hu" 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", which cannot be built directly under Windows, can be established in command-line mode.
|
File 0: (. htaccess) (this file is used to change the configuration of Apache)
<files test>
Forcetype application/x-httpd-php
</files> |
Document 1: (test.php)
<?php
/*-------------------------------------
* test.php
*
* File as an entry point for your website
* For initialization and entry
* Call to perform controler calls
*
-------------------------------------*/
Require "application.php";
$AA = new Application ();
$aa->parse ();
$aa->go ();
?>
|
Document 2: (goodcontroler.php)