PHP-在名称空间中导入类

时间:2018-11-30 14:08:06

标签: php namespaces

假设我有一个命名空间:

<?php
namespace Example;

class Load {
  function load_classes() {
    foreach( glob(__DIR__ . "/*.php") as $filename ) {
      require( $filename );
    }
  }
}
?>

在同一目录中,我还有另一个文件“ sample.php”,其内容如下:

<?php
class Test {
  static function test() {
    echo 1;
  }
}
?>

认为第二个代码没有定义名称空间,如何在“示例”之外的其他名称空间中使用“测试”类?

0 个答案:

没有答案
相关问题