PHP头条
热点:

thinkphp-关于php命名空间的问题求解答啊


命名空间thinkphpphp

目录结构

如上图这是目录结构

这是test.class.php内的代码

namespace Common;

class test{
public function __construct(){

}
}

这是IndexController.class.php下的代码

namespace Home\Controller;
use Think\Controller;
class IndexController extends Controller {
public function index(){
$test = new \Common\test();
}
}

我想达到的效果是在test.class.php下不把命名空间命名成namespace Common\Common;而是命名为namespace Common;也能在IndexController.class.php实例化test.class.php 这样就可以减少一个目录,因为我在另一个业务里有一个目录名是变量 想跳过那个目录 能实现上图的实例吗 真心求解答

www.phpzy.comtrue/phpyy/1394.htmlTechArticlethinkphp-关于php命名空间的问题求解答啊 命名空间thinkphpphp 如上图这是目录结构 这是test.class.php内的代码 namespace Common; class test{ public function __construct(){ } } 这是IndexController.class.php下的代...

相关文章

相关频道:

PHP之友评论

今天推荐