Heim  >  Artikel  >  Backend-Entwicklung  >  thinkphp-关于php命名空间的问题 求解答啊

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

WBOY
WBOYOriginal
2016-06-02 11:33:54681Durchsuche

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

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn