I have 3 source files as follows:
first one is source_class.php
class MacMini
{
public $memory = "16 Gigabytes";
public $cpu = "Intel Core i7 @ 2.6GHz";
public $HD = "1TB @ 5200 rpms";
public function mem()
{
return $this->memory;
}
public function centralPU()
{
return $this->cpu;
}
public function hard_drive()
{
return $this->HD;
}
}
///////////////////////////////////////////////////
second one is serialize.php
include "source_class.php";
$myMini = new MacMini;
$myMini->cpu = "Intel Core i7 @ 3.4GHz";
$serialized = serialize($myMini);
file_put_contents("store", $serialized);
//////////////////////////////////////////////
third one is unserialize.php
include "source_class.php";
$data = file_get_contents("store");
$unserialized = unserialize($data);
$myMini = new MacMini;
echo $myMini->cpu;
it produces the following output: "Intel Core i7 @ 2.6GHz"
Why, if the property of the cpu was changed in the serialize.php file, is it not reflected in the unserialization? I checked the raw data contents of the serialized file, "store" and the cpu property is reflected in the serialized file but when it's unserialized in unserialize.php the property change is not reflected. Why is that? Can anyone explain?