DOMDocument_saveHTMLFile_basic.phpt 876 B

123456789101112131415161718192021222324252627
  1. --TEST--
  2. DOMDocument::saveHTMLFile() should dump the internal document into a file using HTML formatting
  3. --CREDITS--
  4. Knut Urdalen <knut@php.net>
  5. #PHPTestFest2009 Norway 2009-06-09 \o/
  6. --EXTENSIONS--
  7. dom
  8. --FILE--
  9. <?php
  10. $filename = __DIR__."/DOMDocument_saveHTMLFile_basic.html";
  11. $doc = new DOMDocument('1.0');
  12. $root = $doc->createElement('html');
  13. $root = $doc->appendChild($root);
  14. $head = $doc->createElement('head');
  15. $head = $root->appendChild($head);
  16. $title = $doc->createElement('title');
  17. $title = $head->appendChild($title);
  18. $text = $doc->createTextNode('This is the title');
  19. $text = $title->appendChild($text);
  20. $bytes = $doc->saveHTMLFile($filename);
  21. var_dump($bytes);
  22. echo file_get_contents($filename);
  23. unlink($filename);
  24. ?>
  25. --EXPECT--
  26. int(126)
  27. <html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>This is the title</title></head></html>