Home > Backend Development > PHP Tutorial > Usage and description of php namespace

Usage and description of php namespace

WBOY
Release: 2016-07-29 09:07:05
Original
1023 people have browsed it

Namespace is to solve the problem of duplicate names.

For example, there are model files in both directories a and b;
Add namespace a to the beginning of the model file under the name of directory a;

<code><span>namespace</span><span>a</span>;
<span><span>class</span><span>model</span>{</span>
}</code>
Copy after login

Add namespace b to the beginning of the model file under the name of directory b;

<code><span>namespace</span><span>b</span>;
<span><span>class</span><span>model</span>{</span>
}</code>
Copy after login

When referencing the file new /space name/class name (model here)

<code><span>require</span>(<span>"a\model.class.php"</span>);
<span>$model</span> = <span>new</span>  /a/model;</code>
Copy after login
').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

The above introduces the usage and description of PHP's namespace (namespace), including the relevant content. 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