yii学习第一课 《命名空间》

<?php

namespace ac;

class Apple {

    function getInfo() {
        echo 'this is a<br>';
    }

}
<?php

namespace def;

class Apple {

    function getInfo() {
        echo 'this is b<br>';
    }

}
<?php
class Apple {

    function getInfo() {
        echo 'this is C<br>';
    }

}

调用处:

<?php

require_once("A.php");
require_once("B.php");
require_once("C.php");
use acApple;
use defApple as BApple;

$a_app = new Apple();
$a_app->getInfo();

$b_app=new BApple();
$b_app->getInfo();

$c_app=new Apple();
$c_app->getInfo();

this is a
this is b
this is C

原文地址:https://www.cnblogs.com/panqingqiang/p/5100464.html