Skip to content

Instantly share code, notes, and snippets.

@koriym
Created August 21, 2013 08:14
Show Gist options
  • Save koriym/6291661 to your computer and use it in GitHub Desktop.
Save koriym/6291661 to your computer and use it in GitHub Desktop.
Serialized object singleton test (2)
<?php
class Depedency
{
public $value;
}
class A
{
public $dependency;
public function setDependency($dependency)
{
$this->dependency = $dependency;
}
}
class B
{
public $dependency;
public function setDependency($dependency)
{
$this->dependency = $dependency;
}
}
$saved = file_get_contents('saved.php');
list($a, $b, $d) = unserialize($saved);
$d->value = 20;
echo $a->dependency->value . PHP_EOL;
echo $b->dependency->value . PHP_EOL;
// 20
// 20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment