Php Symfony 4:Unsezialise(),[“允许的”类=>;false]错误
我正在用Synfony 4开发一个网站,并创建了一个管理员登录。我使用序列化和非序列化Php Symfony 4:Unsezialise(),[“允许的”类=>;false]错误,php,symfony,web,serialization,symfony4,Php,Symfony,Web,Serialization,Symfony4,我正在用Synfony 4开发一个网站,并创建了一个管理员登录。我使用序列化和非序列化 /** * @inheritDoc */ public function serialize() { // TODO: Implement serialize() method. return serialize([ $this->id, $this->username,
/**
* @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])代码>不起作用,并在Intellij IDEA中显示“方法调用提供了2个参数,但方法签名使用1个参数”作为错误。
我不明白这意味着什么,也找不到关于它的任何东西
我认为基本方法只需要unserialize($serialized)
或类似的东西,但是当我填写表单并发送它时,什么都没有发生。我们不知道这些方法的上下文,但是使用$this->unserialize(…)
,您正在调用当前函数(公共函数unserialize($serialized){…}
)
您可能希望使用默认的PHP序列化程序。因此,您可能应该执行以下操作:
public function unserialize($serialized)
{
list(
$this->id,
$this->username,
$this->password
) = unserialize($serialized, ["allowed_classes" => false]);
}
如果“什么也没发生”,没有关于这个问题的更多信息,我们将无法帮助您!
您是否尝试添加任何转储以检查正在发生的情况?我们不知道这些方法的上下文,但使用$this->unserialize(…)
,您正在调用当前函数(公共函数unserialize($serialized){…}
)
您可能希望使用默认的PHP序列化程序。因此,您可能应该执行以下操作:
public function unserialize($serialized)
{
list(
$this->id,
$this->username,
$this->password
) = unserialize($serialized, ["allowed_classes" => false]);
}
如果“什么也没发生”,没有关于这个问题的更多信息,我们将无法帮助您!
您是否尝试添加任何转储来检查发生了什么?$this->unserialize()
与PHP的内部unserialize()
不同-您想要第二个$this->unserialize
??这就是调用您已经使用的方法。1) 位循环2)$this->unserialize()
只有一个参数,您要传递两个参数。松开$this
,因此您只需调用unserialize()
$this->unserialize()
与PHP的内部unserialize()
不同-您想要第二个$this->unserialize
??这就是调用您已经使用的方法。1) 位循环2)$this->unserialize()
只有一个参数,您要传递两个参数。松开$this
,您只需调用取消序列化()