/*First of all, the namespace exists to solve the problem of naming conflicts when referencing different classes*/
/*1. Define namespace*/
namespace My;
class A{};
namespace Your;
class A{};
/ *2. Reference namespace in the same project*/
namespace My;
class A{};
//Direct reference (use unqualified name)
$a = new A() ;
/ /Reference the namespace starting from the root directory (fully qualified name)
$b=namespaceMyA();
namespace Myonetwo;
class A{};
namespace Your;
class A{};
use Myonetwo //If the ending is named space is the default The last paragraph is an alias, similar to adding an environment variable $obj=new twoA();
$obj=new MyonetwoA();
use MyonetwoA as My A // If it ends with a class name, it is equivalent to the shortcut
http://www.bkjia.com/PHPjc/1095473.html
www.bkjia.com
true
http: //www.bkjia.com/PHPjc/1095473.html
TechArticle
php namespace, php namespace usage/*First of all, the existence of namespace is to solve the problem of naming names in different classes. Conflict issues*/ /*1. Define namespace*/ namespace My; class A{}; na...