Blogger Information
Blog 28
fans 0
comment 0
visits 19709
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
1031 路由MVC索引 20191031 2000-2200
没有人的夏天的博客
Original
654 people have browsed it

一个简单的 MVC 路由索引

说明:点击页面,判断get值 调用不同的类方法返回值。


分配器 1031.01.php

<?phpinclude __DIR__ . '/controller/config.php';include __DIR__ . '/Views/index.php';

controller/config.php

<?php
include __DIR__ . '/../Model/function.php';
// 分配路由 

if (empty($_GET)) {    $_GET = ['home' => ""];}if (!empty($_GET)) {    $a = array_keys($_GET)[0];    $b = index::$a($a);}

model/function.php

<?php

class Index{    public static function __callStatic($name, $arguments = [])    {        return "路由是" . $name;    }}

view/index.php

<!DOCTYPE html><html lang="en">
<head>    <meta charset="UTF-8">    <meta name="viewport" content="width=device-width, initial-scale=1.0">    <meta http-equiv="X-UA-Compatible" content="ie=edge">    <title>20191031MVC</title></head>
<body>    <div class="pp">        <ul>            <li><a href="?home"><span>首页</span></a></li>            <li><a href="?news"><span>新闻</span></a></li>            <li><a href="?produt"><span>产品</span></a></li>            <li><a href="?service"><span>服务支持</span></a></li>            <li><a href="?about"><span>关于我们</span></a></li>        </ul>    </div>    <div class="result">        <span><?php echo $b;                ?> </span>    </div></body>
</html>

效果图

TIM截图20191101150101.pngTIM截图20191101150052.pngTIM截图20191101150043.pngTIM截图20191101150031.png

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