开发者

Calling a static method from a class in another namespace in PHP

开发者 https://www.devze.com 2023-03-18 12:49 出处:网络
This code bellow gives me this error : Class \'MyNamespace\\Database\' not found. How do I reference a class that belongs to no namespace, from inside one ?

This code bellow gives me this error : Class 'MyNamespace\Database' not found. How do I reference a class that belongs to no namespace, from inside one ?

Class Database
{
    public function request()
    {
    }
}

namespace MyNamespace
{
    cl开发者_如何转开发ass MyClass
    {
        public function myFuction()
        {
            Database::request();
        }
    }
}


Try with

\Database::request();

Also see Namespace Basics Example 1 in the PHP Manual

0

精彩评论

暂无评论...
验证码 换一张
取 消