只要是定义过 $request 这个类,这样就行。

解决方案 »

  1.   

    $request现在是一个请求的页面,可以这样创建,是什么原因呢?
      

  2.   

    可以这么创建 
    原代码
    $model = new test();
    也可以这样写
    $name = 'test';
    $model = new $name();传说中的MVC?
      

  3.   

    感谢你们的回复;ten789(),不知你的说法有没有权威性的说明文字?谢谢!
      

  4.   

    ten789(),假如:$name = 'test';
    $model = new $name();里面的test是一个类中一个函数,也可以创建吗?详细请看http://club.phpe.net/index.php?act=ST&f=15&t=14693&s=
      

  5.   

    我也是这样想,http://club.phpe.net/index.php?act=ST&f=15&t=14693&s=上面的代码我很疑惑...
      

  6.   

    可以!只要相应的类存在    function run()
        {
            //取得请求的页面
            $request = $this->getRequest();        //调试信息
            if( IB_DEBUG == true )
            {
                echo "current request is <font color='red'>" . $request . "</font><br/>";
            }        //是否为非法请求
            if( $this->isValidRequest( $request ) )
            {
                //包含请求页面
                $page = $request . IB_REQUEST_EXT;
                //echo $page;
                require_once( $page );            //初始化请求的类
                echo $request;
                $module = new $request( $this );
                
                //执行请求
                $module->process();
            }
            else        //非法请求
            {
                $this->halt( "invalid request" );
            }
        }请注意 $request 是如何赋值的
      

  7.   

    xuzuning(唠叨)大哥能不能解释一下呢?或者提供一个比较易理解的例子学习...
      

  8.   

    class test {
    }$request = 'test';
    $module = new $request();
    echo get_class($module);//out test而
    $request = 'test1';
    $module = new $request();
    将产生 Fatal error: Class 'test1' not found in ....