且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用PHP 5.3名称空间按字符串实例化类

更新时间: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.