DOMDocument_standalone_basic.phpt 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. --TEST--
  2. Tests DOMDocument::standalone get, set, and functionality
  3. --CREDITS--
  4. Chris Snyder <chsnyder@gmail.com>
  5. # TestFest 2009 NYPHP
  6. --EXTENSIONS--
  7. dom
  8. --FILE--
  9. <?php
  10. // create dom document
  11. $dom = new DOMDocument;
  12. $xml = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
  13. <!DOCTYPE s1 PUBLIC "http://www.ibm.com/example.dtd" "example.dtd">
  14. <s1>foo</s1>';
  15. $dom->loadXML($xml);
  16. if(!$dom) {
  17. echo "Error while parsing the document\n";
  18. exit;
  19. }
  20. echo "Standalone DOMDocument created\n";
  21. $test = $dom->standalone;
  22. echo "Read initial standalone:\n";
  23. var_dump( $test );
  24. $dom->standalone = FALSE;
  25. $test = $dom->standalone;
  26. echo "Set standalone to FALSE, reading again:\n";
  27. var_dump( $test );
  28. $test = $dom->saveXML();
  29. echo "Document is no longer standalone\n";
  30. var_dump( $test );
  31. echo "Done";
  32. ?>
  33. --EXPECT--
  34. Standalone DOMDocument created
  35. Read initial standalone:
  36. bool(true)
  37. Set standalone to FALSE, reading again:
  38. bool(false)
  39. Document is no longer standalone
  40. string(136) "<?xml version="1.0" encoding="UTF-8" standalone="no"?>
  41. <!DOCTYPE s1 PUBLIC "http://www.ibm.com/example.dtd" "example.dtd">
  42. <s1>foo</s1>
  43. "
  44. Done