Home > Backend Development > PHP Tutorial > 90 php namespace

90 php namespace

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

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>
Copy after login

test2.php

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

test.php

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

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>
Copy after login

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>
Copy after login

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>
Copy after login

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.

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