实例化类的时候不能带参数

浏览:358 发布日期:2019/11/23 分类:求助交流
<?php
namespace app\index\controller;

use \think\Controller;

class User extends Controller
{
//用户登录
public function login()
{
$wechat = new Wechat('aa','bb');
$res = $wechat -> oauth();
return $res;
}
}


<?php
namespace app\index\controller;

use \think\Controller;
use app\index\model\User as UserModel;

class Wechat extends Controller
{
public $appid = null;
public $appsecret = null;
public $redirect = 'http://http://38h2b8.natappfree.cc/index.php/index/wechat/oauth';

//构造函数,获取Access Token
public function _initialize($appid,$appsecret)
{
parent::_initialize();
$this->appid = $appid;
$this->appsecret = $appsecret;
}

//用户授权登录
public function oauth()
{
……
}
}

报错信息:
Declaration of app\index\controller\Wechat::_initialize($appid, $appsecret, $redirect) should be compatible with think\Controller::_initialize()
最佳答案
评论( 相关
后面还有条评论,点击查看>>