开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜