<?php
namespace plugin\took\app\controller;
use support\Request;
class Config{
protected $plugin = null;
public function __construct(){
$this->request = Request();
$this->plugin = $this->request->plugin; //获取当前插件名称
$this->bot = $this->request->get("bot","null"); //这里是获取的get参数
if($this->bot == 'null'){
return "获取get参数bot 失败";
}
}
protected function send($msg){
return $this->plugin;
}
}
应用插件base.php 代码 继承Config.php
<?php
namespace plugin\took\app\controller;
use support\Request;
use support\Response;
class Base extends Config{
public function plugin(){
return $this->plugin;
}
}
示例代码:
$Base = new \plugin\took\app\controller\Base;
$plugin = $Base->plugin();
这时候根本拿不到 plugin 名,还有什么其它办法拿到 plugin 名吗?
以及如何在 $Base = new \plugin\took\app\controller\Base; 时 给到config中:$this->bot = $this->request->get("bot","null"); 怎么给传这个bot 参数过去?
我如果用:域名/app/took/Base/plugin?bot=ssssssss
这样就可以获取到plugin 和 bot 参数
按照你的需求,Config的构造函数里直接写死
$this->plugin = 'took';
就好了也对。。