-1
我想通過一個類作爲參數,但我不知道它是否可能。通過一個類作爲參數
class User {
var $name;
}
class UserRepository {
private $type;
public function __construct(Class) {
$this->type = Class;
}
public function getInstance() {
return new $this->type;
}
}
$obj = new UserRepository(User);
我接受其他方式的建議。
將與命名空間的工作,它呢? –
@TafarelChicotti它適用於您的示例,您將不得不親自嘗試命名空間。 – jeroen