0

我有这个代码。

    $contrl = stripslashes($this->params['controller'].'Controller'); //PostController
    $obj = new $contrl(); // What's won't work
    //this don't work too
    $contrl = 'PostController';
    $obj = new $contrl();
    //but this work good
    $obj = new PostController();

我不明白为什么会发生这种情况以及如何解决?

4

1 回答 1

0

我没有测试过它,但我很确定它应该这样做(根据文档):

$obj = new $contrl;
于 2013-07-28T14:03:14.960 回答