在php名称空间中,我需要每个文件吗
如果我使用名称空间,例如,我有以下目录树在php名称空间中,我需要每个文件吗,php,namespaces,Php,Namespaces,如果我使用名称空间,例如,我有以下目录树 Test/someclass.php Test/someotherclass.php 我能简单地做吗 use \Test\someotherclass 或者我需要先做 require 'Test/someotherclass.php' 然后我就可以使用这个类了 因为目前当我这样做的时候,我得到了以下错误 致命错误:在中找不到类“Test\someOtherClass” 第10行的C:\xampp\htdocs\test\test\someClas
Test/someclass.php
Test/someotherclass.php
我能简单地做吗
use \Test\someotherclass
或者我需要先做
require 'Test/someotherclass.php'
然后我就可以使用这个类了
因为目前当我这样做的时候,我得到了以下错误
致命错误:在中找不到类“Test\someOtherClass”
第10行的C:\xampp\htdocs\test\test\someClass.php
如注释中所述,
名称空间
和使用
语句默认情况下不加载任何内容。但是您可以使用基于命名空间的。你有一个叫做自动加载的标准 名称空间!==自动装弹机。。。。。使用自动加载器来包含所需的类文件。请查看并