<?php // 路由分发 // 加载所有的依赖 spl_autoload_register(function ($class_name){ require "./controller/{$class_name}.php"; }); // 从路由中获取参数 $action = $_GET['a'] ?? "a"; $control = $_GET['c'] ?? "c"; $action = strtolower($action); // 全部转成小写 $control = ucfirst(strtolower($control)); // 先转成小写,然后将首字母转成大写 $action = $action."Action"; $control = $control."Controller"; // 执行对应的类和方法 $obj = new $control(); $obj -> $action(); ?>