Consider the following code:
myapp1.php:
1 2 3 4 5 6 7 8 9 10 |
<br /> &lt; ?php<br /> namespace AppLib1;<br /> require_once('lib1.php');<br /> require_once('lib2.php');<br /> header('Content-type: text/plain');<br /> echo MYCONST . &quot;n&quot;;<br /> echo MyFunction() . &quot;n&quot;;<br /> echo MyClass::WhoAmI() . &quot;n&quot;;<br /> ?&gt;<br /> |
Although we include both lib1.php and lib2.php, the identifiers MYCONST, MyFunction, and MyClass will only reference code in lib1.php. This occurs because the myapp1.php code is within the same AppLib1 namespace:
result:
1 2 3 4 5 |
<br /> view plainprint?<br /> AppLib1MYCONST<br /> AppLib1MyFunction<br /> AppLib1MyClass::WhoAmI<br /> |