The LyndaMVC mode has many advantages, including single-point control, code separation, rapid development, easy maintenance and expansion in the future, and clear code architecture. None? Phpmvcpattern single-point control simple controller cclassnumbercontrollerextendsdefacontroller controller {public $ modelnull; publicfunction _ const
The Lynda MVC model has many advantages, including single-point control, code separation, rapid development, easy maintenance and expansion in the future, and clear code architecture. None? Php // mvc pattern single-point control // simple controller Cclass NumberController extends defacontroller controller {public $ model = null; public function _ const
Lynda
The MVC mode has many advantages, including single-point control, code separation, rapid development, easy maintenance and extension at the later stage, and clear code architecture. <无>
Model = NumberModel ();} // Vpublic function view ($ value = 0) {echo "The square of this number is :", $ this-> model-> square ($ value) ;}// controller's base class DefaultController {public function run ($ action = 'index', $ id = 0) {if (! Method_exists ($ this, $ action) {$ action = 'index';} return $ this-> $ action ($ id );} // simple output template public function index () {$ html = ""; for ($ I = 1; $ I <10; $ I ++) {$ html. = sprintf ('
', $ I, "INDEX _ $ I");} echo sprintf ("
", $ Html) ;}}// a very simple model that calculates the area of the Quadrilateral Mclass NumberModel {public function square ($ number) {return $ number * $ number ;}} // GET the controller, model, and parameter $ action = isset ($ _ GET ['a'])? $ _ GET ['a']: 'index'; $ module = isset ($ _ GET ['M'])? $ _ GET ['M']: ''; $ id = isset ($ _ GET ['id'])? $ _ GET ['id']: ''; // find our controller switch ($ module) {case 'number': $ controller = new NumberController (); break; default: $ controller = new DefaultController (); break ;}//
Index_1$ Controller-> run ($ action, $ id );