ClassThatImplementsSerializable.php 322 B

12345678910111213141516
  1. <?php
  2. class ClassThatImplementsSerializable implements Serializable
  3. {
  4. public function serialize()
  5. {
  6. return get_object_vars($this);
  7. }
  8. public function unserialize($serialized)
  9. {
  10. foreach (unserialize($serialized) as $key => $value) {
  11. $this->{$key} = $value;
  12. }
  13. }
  14. }