Home  >  Article  >  Backend Development  >  PHP namespace namespace usage example analysis

PHP namespace namespace usage example analysis

高洛峰
高洛峰Original
2017-01-06 13:39:061096browse

The examples in this article describe the usage of PHP namespace namespace. Share it with everyone for your reference. The details are as follows:

namespace (namespace) is equivalent to functions and classes. It divides an area. This way, the same class can be required on the same page and the same name can be used. Function
: It is rarely used in projects

name.php:

';
  }
  public function name(){
    echo 'i use space'.'
'; } } //$me = new me(); function me(){ echo 'is me'.'
'; }

common.php:

';
  }
}
name();
i\me();
$com = new me();

The running effect is as follows:

PHP namespace namespace usage example analysis

I hope this article will be helpful to everyone in PHP programming.

For more articles related to PHP namespace namespace usage example analysis, please pay attention to the PHP Chinese website!

Statement:
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