PHP: simple implementation of MVC framework, phpmvc framework _ PHP Tutorial

Source: Internet
Author: User
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 ,...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.