Home >Backend Development >PHP Tutorial >thinkphp-关于php命名空间的问题 求解答啊

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

WBOY
WBOYOriginal
2016-06-02 11:33:54721browse

命名空间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 这样就可以减少一个目录,因为我在另一个业务里有一个目录名是变量 想跳过那个目录 能实现上图的实例吗 真心求解答

Statement:
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