我正在使用 Synfony 4 开发一个网站并创建了一个管理员登录。我使用了序列化和反序列化。 /** * @inheritDoc */ public function serialize() { // TODO: Implement serialize() method. return serialize([ $this->id, $this->username, $this->password ]); } /** * @inheritDoc */ public function unserialize($serialized) { // TODO: Implement unserialize() method. list( $this->id, $this->username, $this->password ) = $this->unserialize($serialized, ["allowed_classes" => false]); }最后$this->unserialize($serialized, ["allowed_classes" => false]);不起作用并显示“方法调用提供了 2 个参数,但方法签名使用 1 个参数”作为 Intellij IDEA 中的错误。我不明白这意味着什么,也找不到任何关于它的信息。我认为基本方法只是想要unserialize($serialized)或类似的东西,但是当我填写表格并发送它时,什么也没有发生。
1 回答
呼唤远方
TA贡献1856条经验 获得超11个赞
我们不知道这些方法的上下文,但使用$this->unserialize(...),您正在调用当前函数 ( public function unserialize($serialized){...})
您可能想要使用默认的 PHP 序列化程序。因此,您可能应该执行以下操作:
public function unserialize($serialized)
{
list(
$this->id,
$this->username,
$this->password
) = unserialize($serialized, ["allowed_classes" => false]);
}
如果“什么都没发生”,没有关于该问题的更多信息,我们将无法为您提供帮助!您是否尝试添加任何转储来检查发生了什么?
- 1 回答
- 0 关注
- 62 浏览
添加回答
举报
0/150
提交
取消