'Use' 命名空间不执行任何操作 - PHP

'Use' namespace doesn't do anything - PHP

所以我得到了以下代码,但由于某种原因,use 语句似乎没有做任何事情。

class Image {
    use \App\Traits\File;

    public static function get()
    {
         $image_url = File::getVersion()
    }
}

引发错误 Uncaught Error: Class 'File' not found。但是如果我把它改成 $image_url = \App\Traits\File::getVersion().

就可以了

有人知道为什么吗?

相反,我会在 Http 文件夹中创建 Traits 目录。我在其中创建了文件 File。在 class、

use App\Http\Traits\File;
class Image {
    use File;
    public static function get()
    {
         $image_url = File::getVersion()
    }
}

以上应该是使用命名空间和特征的正确语法。