如下:
a.php
1 2 3 4 5 6 |
<?php namespace A; use B\Group; include("b.php"); new Group(); |
b.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
<?php namespace A; class Group{ function __construct(){ echo "Group in A"; } } namespace B; class Group{ function __construct(){ echo "Group in B"; } } |
php a.php
如果 a.php 中
1 |
use B\Group; |
则输出的是 Group in B;
否则: 输出Group in A;
至少不会冲突