PHP: simple MVC framework and phpmvc framework. PHP: simple implementation of MVC framework, phpmvc framework 1. the full name of MVC is ModelViewController. it is short for model-view-controller. it is a software design model, simple implementation of MVC framework in PHP, and phpmvc framework.
1. Overview
The full name of MVC is Model View Controller, short for model-view-controller. it is a Model of software design, organize code by means of separation of business logic, data, and interface display, and integrate the business logic into a component to improve and personalize the custom interface and user interaction, you do not need to rewrite the business logic. MVC is uniquely developed to map traditional input, processing, and output functions in a logical graphical user interface structure.
2. code structure
3. code implementation
Show (); eval ('$ obj = new '. $ name. 'controller (); $ obj-> '. $ method. '();');} // Model call function M ($ name) {require_once ('libs/Model /'. $ name. 'model. class. php '); eval (' $ obj = new '. $ name. 'model (); '); return $ obj;} // View call function V ($ name) {require_once ('libs/View /'. $ name. 'view. class. php '); eval (' $ obj = new '. $ name. 'view (); '); return $ obj;} // filter the invalid value function daddslashes ($ str) {return (! Get_magic_quotes_gpc ())? Addslashes ($ str): $ str ;}?>
Call the controller, send an instruction to it. Step 2 controller-> select a suitable model based on the instruction. step 3 model-> obtain the corresponding data based on the controller command. step 4 controller-> select the corresponding view based on the instruction. step 5 View -> display the data obtained in step 3 as you want */require_once ('View/testView. class. php '); require_once ('Model/testModel. class. php '); require_once ('Controller/testController. class. php '); $ testController = new testController (); $ testController-> show ();?>
Get (); $ testView = new testView (); $ testView-> display ($ data); */$ testModel = M ('test '); $ data = $ testModel-> get (); $ testView = V ('test'); $ testView-> display ($ data) ;}}?>
Running result:
Summary 1. MVC full name is Model View Controller, short for model-view-controller, a software design Model ,...