current_error.phpt 683 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. --TEST--
  2. SimpleXML: invoking current() after the iterator has already been consumed
  3. --EXTENSIONS--
  4. simplexml
  5. --FILE--
  6. <?php
  7. $xml =<<<EOF
  8. <?xml version='1.0'?>
  9. <root>
  10. <elem/>
  11. </root>
  12. EOF;
  13. $sxe = simplexml_load_string($xml);
  14. try {
  15. $sxe->current();
  16. } catch (Error $exception) {
  17. echo $exception->getMessage() . "\n";
  18. }
  19. for ($sxe->rewind(); $sxe->valid(); $sxe->next()) {
  20. var_dump($sxe->key(), $sxe->current());
  21. }
  22. try {
  23. $sxe->current();
  24. } catch (Error $exception) {
  25. echo $exception->getMessage() . "\n";
  26. }
  27. ?>
  28. --EXPECT--
  29. Iterator not initialized or already consumed
  30. string(4) "elem"
  31. object(SimpleXMLElement)#3 (0) {
  32. }
  33. Iterator not initialized or already consumed