PHP 类和继承、序列化
序列化变量似乎没有保留扩展类的状态。
我有一个类,直接从接受序列化变量的地方调用:
class Main extends Admin {
function __construct($serialized){
parent::__construct($serialized);
}
.... (omitted)
}
class Admin extends Page{
var $pageargs;
function __construct($should_still_be_serialized_form){
$this->pageargs = unserialize($should_still_be_serialized_form); }}
在管理类中,我收到错误:unserialize() 期望参数 1 为字符串,在(管理类文件)中给出的数组...
这是 php 处理继承的方式?或者我的代码有问题?
Serialized varibale does not seem to retain its state from classes that were extended.
I have a class, called directly from somewhere that accepts a serialized variable:
class Main extends Admin {
function __construct($serialized){
parent::__construct($serialized);
}
.... (omitted)
}
class Admin extends Page{
var $pageargs;
function __construct($should_still_be_serialized_form){
$this->pageargs = unserialize($should_still_be_serialized_form); }}
In admin class i get error: unserialize() expects parameter 1 to be string, array given in (admin class file)...
Is this the way php handles inheritance? or something is wrong with my code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
似乎 $should_still_be_serialized_form 是数组而不是序列化字符串。检查您是否传递了正确的参数 - print_r($should_still_be_serialized_form)。
Seems that $should_still_be_serialized_form is array instead of serialized string. Check out did you pass correct param - print_r($should_still_be_serialized_form).