Skip to content

Instantly share code, notes, and snippets.

@biozshock
Last active October 27, 2015 17:18
Show Gist options
  • Save biozshock/c2b2afd3f5e2ba36289d to your computer and use it in GitHub Desktop.
Save biozshock/c2b2afd3f5e2ba36289d to your computer and use it in GitHub Desktop.
<?php
class A implements Serializable
{
public function serialize()
{
$dt = new \DateTime();
return serialize([
$dt,
serialize([$dt])
]);
}
public function unserialize($serialized)
{
$a = unserialize($serialized);
unserialize($a[1]);
}
}
$a = new A();
$s = serialize($a);
$d = unserialize($s);
var_dump($s);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment