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
精彩评论