DOMDocument_saveHTMLFile_basic.phpt 931 B

1234567891011121314151617181920212223242526272829
  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. --SKIPIF--
  7. <?php
  8. require_once dirname(__FILE__) .'/skipif.inc';
  9. ?>
  10. --FILE--
  11. <?php
  12. $filename = dirname(__FILE__)."/tmp_savehtmlfile".time().".html";
  13. $doc = new DOMDocument('1.0');
  14. $root = $doc->createElement('html');
  15. $root = $doc->appendChild($root);
  16. $head = $doc->createElement('head');
  17. $head = $root->appendChild($head);
  18. $title = $doc->createElement('title');
  19. $title = $head->appendChild($title);
  20. $text = $doc->createTextNode('This is the title');
  21. $text = $title->appendChild($text);
  22. $bytes = $doc->saveHTMLFile($filename);
  23. var_dump($bytes);
  24. echo file_get_contents($filename);
  25. unlink($filename);
  26. ?>
  27. --EXPECTF--
  28. int(126)
  29. <html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>This is the title</title></head></html>