PageRenderTime 38ms CodeModel.GetById 13ms RepoModel.GetById 1ms app.codeStats 0ms

/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
Possible License(s): LGPL-2.1, BSD-2-Clause, BSD-3-Clause, MPL-2.0-no-copyleft-exception, MIT, LGPL-2.0, Apache-2.0
  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===