In front of a blog post namespace, there is nothing more than a layer of relative paths, the only thing to note is that using use, import a namespace usage.
<?php/** * Multilevel Namespace */namespace Beijing\haidian; Class animal{Public $obj = ' dog<br> '; static $name = ' rhubarb <br> '; } function getmsg () {echo ' Beijing Haidian <br> '; } namespace Shanghai\putuo; Class animal{Public $obj = ' pig<br> '; static $name = ' hem <br> '; } function getmsg () {echo ' Shanghai Putuo <br> '; }/** * Access mode */$animal = new animal (); $animal 2 = new \beijing\haidian\animal (); Echo $animal->obj; Print Result: pig echo $animal 2->obj; Print Result: Dog echo Animal:: $name; Print Result: Hem echo \beijing\haidian\animal:: $name; Printing results: Rhubarb/** * Access: 3, Limited name access method (relative path) * Use to import a namespace */use Beijing\haidian; Haidian\getmsg (); Printed result: Beijing Haidian $animal 3 = new Haidian\animal (); Echo $animal 3->obj; Print Result: Dog echo haidian\animal:: $name; Printing results: Rhubarb
The above is PHP development (-thinkphp5.0) (3) Multilevel namespace-phpstorm content, more relevant content please pay attention to topic.alibabacloud.com (www.php.cn)!