本文主要是介绍thinkphp5.1跨控制器调用方法--示例,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
<?phpnamespace app\index\controller;use app\index\model\Profile;
use think\Controller;
use think\facade\Url;
use think\Request;class Test extends Controller
{public function fenCeng(){//方法1:跨模块访问控制器
// $event = \think\facade\App::controller('app/Index');//使用助手函数更简单
// $event = controller('app/Index');//方法2:不跨模块调用别的目录下的类的方法$e2 = \think\facade\App::controller('Blog','test');//使用助手函数更简单$e2 = controller('Blog','test');$res = $e2->kua();// $res = $event->index();var_dump($res);}
}
<?phpnamespace app\index\test;class Blog
{public function kua(){return '跨控制器调用示范';}
}
<?phpnamespace app\app\controller;use think\Controller;class Index extends Controller
{public function index(){return '入口文件绑定到模块app';}
}
这篇关于thinkphp5.1跨控制器调用方法--示例的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!