Home > Backend Development > PHP Tutorial > What is a namespace? PHP namespace example description

What is a namespace? PHP namespace example description

WBOY
Release: 2016-07-29 08:44:23
Original
889 people have browsed it

Copy the code The code is as follows:


namespace bakbaba;
function bab(){
echo "bi";
}
namespace kkk;
function k1(){
echo "k1";
}
bakbab abab ();//Use other namespaces under the kkk namespace, pay attention to the previous
use bakbaba as b;//Still under the kkk namespace, but the following method is also correct when using aliases
#use bakbaba as b;//You don’t need to use the number before it
bbab();//When using the namespace under an alias, there should be no number before it
k1();//No error is reported when calling this function, indicating that use does not affect the current namespace

The above has introduced what a namespace is and an example of a PHP namespace, including what a namespace is. I hope it will be helpful to friends who are interested in PHP tutorials.

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