<?php $_SERVER[‘REQUEST_URI‘] = ‘/post/edit/1024?foo=bar‘; $uri = explode(‘/‘, parse_url($_SERVER[‘REQUEST_URI‘], PHP_URL_PATH)); var_export($uri); //输出 array ( 0 => ‘‘, 1 => ‘post‘, //控制器(控制器存在就require) 2 => ‘edit‘, //方法 3 => ‘1024‘, //参数(获取参数foo就用传统的$_GET[‘foo‘]) ) $class = $uri[1]; require ‘controller/‘.$class.‘.php‘; // controller/post.php $object = new $class(); $action = $uri[2]; $parameter = $uri[3]; echo call_user_func_array(array($object, $action), array($parameter)); //调用对象里的方法并传参 controller/post.php: class post { public function edit($id) { return ‘$‘.__CLASS__.‘->‘.__FUNCTION__.‘(‘.$id.‘)‘; //输出 $post->edit(1024) } }