PHP Development (-thinkphp5.0) (3) Multilevel namespace-phpstorm

Source: Internet
Author: User
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)!

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.