views:

113

answers:

1

Hi!

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?

A: 

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).

c0r0ner
a call to the main class is this: (PHP)$vartoserialize['foo'] = 'bar';$vartoserialize['bar'] = 'foo';eval("\$page = new \$classpage('".serialize($vartoserialize)."')"); and the events take place as stated above to my very post.
jan
print_r showed that it was really an array that was passed when i initially created the code and i forgot about it, it should not be there.
jan