90 php namespace

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

1. If you don’t add a namespace
test1.php

<code><span><span>function</span><span>test</span><span>()</span>
{</span><span>echo</span><span>'test1'</span>;
}</code>

test2.php

<code><span><span>function</span><span>test</span><span>()</span>
{</span><span>echo</span><span>'test2'</span>;
}</code>

test.php

<code><span>require</span><span>'test1.php'</span>;
<span>require</span><span>'test2.php'</span>;</code>

Error:
90 php 命名空间


2. Added namespace

test1.php

<code><span>namespace</span><span>Test1</span>;

<span><span>function</span><span>test</span><span>()</span>
{</span><span>echo</span><span>'test1'</span>;
}</code>

test2.php

<code><span>namespace</span><span>Test2</span>;

<span><span>function</span><span>test</span><span>()</span>
{</span><span>echo</span><span>'test2'</span>;
}</code>

test.php

<code><span>require</span><span>'test1.php'</span>;
<span>require</span><span>'test2.php'</span>;

Test1\test();
<span>echo</span><span>'<br/>*************<br/>'</span>;
Test2\test();</code>

90 php 命名空间

').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 90 PHP namespace, including the relevant 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