我有结构
one.php
src
two.php
one.php文件
<?php
function autoloadSrc($class){
$class = preg_replace('#\\\\#',DIRECTORY_SEPARATOR , $class);
if (file_exists('src' . DIRECTORY_SEPARATOR . $class . '.php'))
require_once('src' . DIRECTORY_SEPARATOR . $class . '.php');
}
spl_autoload_register('autoloadSrc');
$a= new src\Agg();
echo $a -> $b;
?>
two.php文件
<?php
namespace src;
class Agg{
public $b = "hi"
}
?>
但我收到错误,它在one.php文件中找不到类Agg,我做错了什么