Home >Backend Development >PHP Tutorial >91 php namespace 1

91 php namespace 1

WBOY
WBOYOriginal
2016-07-29 09:05:341439browse

1. Use namespace: Basics
91 php 命名空间1
91 php 命名空间1
91 php 命名空间1
91 php 命名空间1

<code><span><span><?php</span><span>namespace</span><span>Foo</span>;

<span><span>function</span><span>strlen</span><span>()</span> {</span><span>echo</span><span>'hello'</span>;
}
<span>const</span> INI_ALL = <span>3</span>;
<span><span>class</span><span>Exception</span> {</span>}

<span>$a</span> = strlen(<span>'hi'</span>); <span>// 调用命名空间 Foo 的strlen()</span><span>$aa</span> = \strlen(<span>'hi'</span>);<span>//调用全局函数strlen</span><span>$b</span> = \INI_ALL; <span>// 访问全局常量 INI_ALL</span><span>$c</span> = <span>new</span> \<span>Exception</span>(<span>'error'</span>); <span>// 实例化全局类 Exception</span><span>echo</span><span>$a</span> . <span>'<br/>'</span>;
<span>echo</span><span>$aa</span> . <span>'<br/>'</span>;
<span>echo</span><span>$b</span> . <span>'<br/>'</span>;
<span>echo</span><span>$c</span> . <span>'<br/>'</span>;
</span></code>

91 php 命名空间1

').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

The above has introduced the 91 PHP namespace 1, including aspects of the content. I hope it will be helpful to friends who are interested in PHP tutorials.

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