我正在尝试为我的网络创建某种调度程序(因为我必须手动执行此操作并且我能做到这一点)
$uri = array_filter(explode("/", filter_input(INPUT_SERVER, "PATH_INFO")));
$_SERVER["URI"] = $uri;
switch (sizeof($uri)) {
case 0:
error();
exit(0);
break;
case 1:
call_user_func("$uri[1]::__construct");
break;
default :
call_user_method_array("$uri[2]", call_user_func("$uri[1]::getInstance"));
break;
}
这就是我所拥有的,但我得到了这个:
发送http://localhost/BACK/index.php/Page/data?asd=1
和
发送http://localhost/BACK/index.php/Page?asd=1
我知道我完全错了,但我找不到帮助...
答案 0 :(得分:0)
我改变了我的功能,现在正常工作
$uri = array_filter(explode("/", filter_input(INPUT_SERVER, "PATH_INFO")));
$_SERVER["URI"] = $uri;
switch (sizeof($uri)) {
case 0:
error();
exit(0);
break;
case 1:
$refClass = new ReflectionClass("$uri[1]");
$class_instance = $refClass->newInstanceArgs((array) null);
break;
default :
$refClass = new ReflectionClass("$uri[1]");
$class_instance = $refClass->newInstanceArgs((array) null);
$class_instance->$uri[2]();
break;
}