1.如果不加命名空间
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>
报错:
2.加了命名空间
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>').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });
以上就介绍了90 php 命名空间,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。