022.phpt 983 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. --TEST--
  2. SimpleXML: Attributes inside foreach
  3. --EXTENSIONS--
  4. simplexml
  5. --FILE--
  6. <?php
  7. $xml =<<<EOF
  8. <?xml version='1.0'?>
  9. <pres><content><file glob="slide_*.xml"/></content></pres>
  10. EOF;
  11. $sxe = simplexml_load_string($xml);
  12. echo "===CONTENT===\n";
  13. var_dump($sxe->content);
  14. echo "===FILE===\n";
  15. var_dump($sxe->content->file);
  16. echo "===FOREACH===\n";
  17. foreach($sxe->content->file as $file)
  18. {
  19. var_dump($file);
  20. var_dump($file['glob']);
  21. }
  22. ?>
  23. --EXPECTF--
  24. ===CONTENT===
  25. object(SimpleXMLElement)#%d (1) {
  26. ["file"]=>
  27. object(SimpleXMLElement)#%d (1) {
  28. ["@attributes"]=>
  29. array(1) {
  30. ["glob"]=>
  31. string(11) "slide_*.xml"
  32. }
  33. }
  34. }
  35. ===FILE===
  36. object(SimpleXMLElement)#%d (1) {
  37. ["@attributes"]=>
  38. array(1) {
  39. ["glob"]=>
  40. string(11) "slide_*.xml"
  41. }
  42. }
  43. ===FOREACH===
  44. object(SimpleXMLElement)#%d (1) {
  45. ["@attributes"]=>
  46. array(1) {
  47. ["glob"]=>
  48. string(11) "slide_*.xml"
  49. }
  50. }
  51. object(SimpleXMLElement)#%d (1) {
  52. [0]=>
  53. string(11) "slide_*.xml"
  54. }