Blogger Information
Blog 30
fans 1
comment 0
visits 24277
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
用MVC搭建一个框架,自动加载视图 20191015
阿乎乎的学习
Original
596 people have browsed it

MVC模型指的是M-model模型,V-view视图,C-controller控制器,MVC模型广泛运用在php框架中,自动加载视图的原理是通过get传参,通过$_GET获取路由中的get参数,通过get参数来派发加载视图。

作业:用MVC搭建一个框架,自动加载视图

<?php
include 'controller/config.php';

include 'view/header.php';

if(!empty($_GET['a'])){

    switch ($_GET['a']){

        case 'director':

            include 'view/director.php';

            break;

        case 'performer':

            include 'view/performer.php';

            break;

        case 'login':

            include 'view/login.php';

            break;

        case 'movies':

            include 'view/movies.php';

            break;

        default:

            include 'view/login.php';

            break;

    }

}
include 'view/footer.php' ;

 

Correction status:qualified

Teacher's comments:写提很清楚
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post