PHP 可以将类名中的对象实例化为字符串吗?
如果类名存储在字符串中,PHP 是否可以从类名实例化对象?
Is it possible in PHP to instantiate an object from the name of a class, if the class name is stored in a string?
推荐答案
是的,当然.
$className = 'MyClass';
$object = new $className;
相关文章