更新时间:2023-11-15 12:01:22
$class = 'Application\Log\MyClass'; $object = new $class();
开头的\引入了(完全限定的)命名空间标识符,但它不是类名本身的一部分.
\
The starting \ introduces a (fully qualified) namespaced identifier, but it's not part of the class name itself.
使用PHP 5.3名称空间按字符串实例化类
PHP可以从类的名称将对象实例化为字符串?
使用 PHP 5.3 命名空间按字符串实例化类
实例化对象时以编程方式使用字符串作为对象名称
实例化一个对象时使用编程方式的字符串作为对象名称