/hphp/test/zend/bad/ext/spl/tests/unserialize.php

http://github.com/facebook/hiphop-php · PHP · 18 lines · 12 code · 2 blank · 4 comment · 0 complexity · 63d6681d3a57a6f184844554b338db04 MD5 · raw file

  1. <?php
  2. $types = array('SplDoublyLinkedList', 'SplObjectStorage', 'ArrayObject');
  3. foreach ($types as $type) {
  4. // serialize an empty new object
  5. $exp = serialize(new $type());
  6. // hack to instanciate an object without constructor
  7. $str = sprintf('C:%d:"%s":0:{}', strlen($type), $type);
  8. $obj = unserialize($str);
  9. var_dump($obj);
  10. // serialize result
  11. $out = serialize($obj);
  12. // both should match
  13. var_dump($exp === $out);
  14. }
  15. ?>
  16. ===DONE===