PHP中的名称空间
请看这个,告诉我你对此有何看法: 1) 我有这样的结构: 2)和代码: 它是Index.php,它的作品:PHP中的名称空间,php,namespaces,traits,spl-autoload-register,Php,Namespaces,Traits,Spl Autoload Register,请看这个,告诉我你对此有何看法: 1) 我有这样的结构: 2)和代码: 它是Index.php,它的作品: <?php namespace Classes; // ^ It doesn't work but when I replace "Classes" to "Test\Classes" It works! // But why? Class Someclass { us
<?php
namespace Classes;
// ^ It doesn't work but when I replace "Classes" to "Test\Classes" It
works!
// But why?
Class Someclass
{
use Traits/Sometrait;
//Yeah, It doesn't work too and when I replace "traits" to "Test\Traits" It works!
// Why? =(
public static function start() {...}
}
?>
**
它是Someclass.php:
<?php
namespace Classes;
// ^ It doesn't work but when I replace "Classes" to "Test\Classes" It
works!
// But why?
Class Someclass
{
use Traits/Sometrait;
//Yeah, It doesn't work too and when I replace "traits" to "Test\Traits" It works!
// Why? =(
public static function start() {...}
}
?>
您遗漏了最重要的部分。。
里面有什么
spl_autoload_register(...);
?
这里设置的函数将决定如何在项目目录中找到类
看看这个
spl_autoload_register(...);