创建一个匿名对象并从中动态调用一个函数

Creating an anonymous object and call a function from it dynamically

我正在尝试为我的网站创建某种类型的调度程序(因为我必须手动完成,我不知道我该怎么做)

$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

我知道我完全错了,但我找不到帮助...

我改变了我的功能,现在可以正常工作了

$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;
}