only the following types of code are affected by namespaces: classes (including abstracts and traits), interfaces, functions and constants.

Namespaces are declared using the namespace keyword. A file containing a namespace must declare the namespace at the top of the file before any other code – with one exception: the declare keyword.

Multiple namespaces may also be declared in the same file. it is recommended to use the alternate bracketed syntax.To combine global non-namespaced code with namespaced code, only bracketed syntax is supported. Global code should be encased in a namespace statement with no namespace name as in.

  • Unqualified name, or an unprefixed class name like $a = new foo(); or foo::staticmethod();. If the current namespace is currentnamespace, this resolves to currentnamespacefoo. If the code is global, non-namespaced code, this resolves to foo. One caveat: unqualified names for functions and constants will resolve to global functions and constants if the namespaced function or constant is not defined. See Using namespaces: fallback to global function/constant for details.
  • Qualified name, or a prefixed class name like $a = new subnamespacefoo(); orsubnamespacefoo::staticmethod();. If the current namespace is currentnamespace, this resolves tocurrentnamespacesubnamespacefoo. If the code is global, non-namespaced code, this resolves tosubnamespacefoo.
  • Fully qualified name, or a prefixed name with global prefix operator like $a = new currentnamespacefoo(); orcurrentnamespacefoo::staticmethod();. This always resolves to the literal name specified in the code,currentnamespacefoo.

The value of __NAMESPACE__ is a string that contains the current namespace name. In global, un-namespaced code, it contains an empty string.

All versions of PHP that support namespaces support three kinds of aliasing or importing: aliasing a class name, aliasing an interface name, and aliasing a namespace name. PHP 5.6+ also allows aliasing or importing function and constant names.

In PHP, aliasing is accomplished with the use operator.

YouTube에서 How to create a production and development mode f… 보기

isao의 IT,게임번역소는 쇠퇴했습니다 : 프로그래밍 입문자를 위한 언어 선택 -3회 인기있는 경량 프로그래밍 언어 5가지