Copyright Notice: 9CBS is this BLOG managed service provider. If this paper involves copyright issues, 9CBS does not assume relevant responsibilities, please contact the copyright owner directly with the article Author.
This is a file that describes how to use PHP to implement MVC mode development. About the technical article on the MVC mode can be located everywhere, so this document will no longer tell the advantages and disadvantages of this model (actually I can't say it), and the child speaks his PHP technology. And in the next series of articles is also based on techniques. First, realize a unified website entry (the method of calling the Controler layer in the MVC, that is, the control layer) You may often see this path on the Internet (http://www.aaa.com/aaa/bbb/aaa?id = 5), make people understand that there are several possibilities: 1. Hidden file extensions, the benefits of this practice, the people's speech, but individual feels no need; 2, use the website Redirect rules, implement virtual paths; 3. Forced file parsing, virtual paths. Use the second third method to realize the unified interface of the website, a reasonable integrated website, better refer to the security and architecture of the website, most of the two ways of the website is built and implemented using the "MVC" mode. Here is an example access path as follows:
... / TEST / ******* / BAD ... / TEST / ******* / Good ("******" can be used Character string replace, "......." is your web path)
The directory structure of the file is as follows
| - .htaccess | - TEST | - Application.php | - Controler / GoodControl.php | - Controler / BadControl.php Note File ".htaccess", can not be created directly under Windows, can be on the command line Built in mode.
File 0 :(. Htaccess) (this file is used to change the Apache configuration method)
Document 1: (Test.php)
php / * ----------------------------------- * Test.php * * as you Site entrance file * Used to initialize and entry * call to perform Controler call * ---------------------------------------------------------------------------------------------- ----- * / Require "Application.php"; $ AA = New Application (); $ aa-> parse (); $ aa-> go ();?>>
File 2: (GoodControlr.php)
php / * ----------------------------------- * GoodControlr.php * * is used Control URL = / test / good access * ------------------------------------- * / Class GoodController {/ * * Control Class Call Method, Unique External Interface * / Function Control () {Echo "this is from goodControl URL = ********* / test / good"; }}?>
File 3: (BadControlr.php)
php / * ----------------------------------- * BadControlr.php * * is used Control URL = / Test / Bad access * ------------------------------------- * / Class BadControler {/ * * Control Class Call Method, Unique External Interface * / Function Control () {Echo "this is from goodControl URL = ********* / test / bad" }}?> File 4: (Application.php)