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()
最佳答案