【发布时间】:2018-11-09 17:45:31
【问题描述】:
我有一个带有字符串的属性的对象。
class Authentication
{
public $secretKey = "secret";
}
当我在 jwt decode 中使用变量时,它会输出:
Object of class stdClass could not be converted to string
我从未将该变量设为对象。
这是我对代码所做的:
$authentication = new Authentication();
$token = array();
$token['id'] = "username_here";
$jwtToken = jwt::encode($token, $authentication->getKey());
echo jwt::decode($jwtToken, $authentication->getKey());
【问题讨论】:
-
jwt::decode你刚刚做了一个对象。 -
那么你的问题是什么?
-
使用 print_r 检查 jwt::decode($jwtToken, $authentication->getKey()); 的输出
-
@Efekan 很抱歉没有这么说。问题是它为什么会输出该错误。
-
@JonStirling 干杯,没有意识到这一点。