i have a class which receive xml data. The class will store the xml data into variables using simpleXML.
The problem is when i store the class in session, the value of the variables is lost.
class file.
class userProfileQuestionObject
{
private $total;
private $name = array();
private $value = array();
private $type = array();
public function setQuestionArray($valueName,$valueValue,$valueType)
{
$this->name[$this->total] = $valueName;
$this->value[$this->total] = $valueValue;
$this->type[$this->total] = $valueType;
$this->total = $this->total+1;
}
function initialize($xmlResult)
{
$this->total = 0;
$sxml = simplexml_load_string($xmlResult);
for($i=0;$i<($sxml->rowAmount);$i++)
{
$this->setQuestionArray($sxml->record->element->fields->name[$i],$sxml->record->element->fields->value[$i],$sxml->record->element->fields->type[$i]);
}
$sxml = NULL;
}
function getName()
{
return $this->name;
}
function getValue()
{
return $this->value;
}
function getType()
{
return $this->type;
}
function getTotal()
{
return $this->total;
}
}
file using the class
include("userProfileQuestionObject.php");
$qo = new userProfileQuestionObject();
$qo->initialize($xmldata);
session_start();
$_SESSION['userProfileQuestionObject'] = $qo;
another file 2
include("classes/userProfileQuestionObject.php");
session_start();
$qo = $_SESSION['userProfileQuestionObject'];
$name = $qo->getName();
echo $name[0];
result .. echo will ouput nothin.
can anyone help? I appreciate it very much.
thank you.