Home > Backend Development > PHP Tutorial > java软件工程师学php -15 php中的namespace 与java中的package

java软件工程师学php -15 php中的namespace 与java中的package

WBOY
Release: 2016-06-13 13:11:54
Original
985 people have browsed it

java程序员学php -15 php中的namespace 与java中的package
php中的namespace跟java中的pakcage一样,都可以解决命名冲突的问题。
比如:
    声明:namespace APP\KENT\CHEN;
    使用:require('xxx.php');
         echo \APP\KENT\CHEN\SOME_CONST;


不同点在于:
  1.写法不一样(废话)
  2.文件的namespace不需要与其实际路径一致
  3.namespace下面不仅可以有类,还可以有常量、函数等其它任何php的东西

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template