serialization_objects_010.phpt 896 B

12345678910111213141516171819202122232425262728293031323334353637
  1. --TEST--
  2. Serialize() must return a string or NULL
  3. --SKIPIF--
  4. <?php if (!interface_exists('Serializable')) die('skip Interface Serialzable not defined'); ?>
  5. --FILE--
  6. <?php
  7. /* Prototype : proto string serialize(mixed variable)
  8. * Description: Returns a string representation of variable (which can later be unserialized)
  9. * Source code: ext/standard/var.c
  10. * Alias to functions:
  11. */
  12. /* Prototype : proto mixed unserialize(string variable_representation)
  13. * Description: Takes a string representation of variable and recreates it
  14. * Source code: ext/standard/var.c
  15. * Alias to functions:
  16. */
  17. Class C implements Serializable {
  18. public function serialize() {
  19. return $this;
  20. }
  21. public function unserialize($blah) {
  22. }
  23. }
  24. try {
  25. var_dump(serialize(new C));
  26. } catch (Exception $e) {
  27. echo $e->getMessage(). "\n";
  28. }
  29. echo "Done";
  30. ?>
  31. --EXPECTF--
  32. C::serialize() must return a string or NULL
  33. Done