📄 function.domdocument-dump-file.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Dumps the internal XML tree back into a file</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.domdocument-document-element.html">DomDocument->document_element</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.domdocument-dump-mem.html">DomDocument->dump_mem</a></div> <div class="up"><a href="ref.domxml.html">DOM XML Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="function.domdocument-dump-file" class="refentry"> <div class="refnamediv"> <h1 class="refname">DomDocument->dump_file</h1> <p class="verinfo">(No version information available, might be only in CVS)</p><p class="refpurpose"><span class="refname">DomDocument->dump_file</span> — <span class="dc-title"> Dumps the internal XML tree back into a file </span></p> </div> <div class="refsect1 unknown"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">string</span> <span class="methodname"><b><b>DomDocument->dump_file</b></b></span> ( <span class="methodparam"><span class="type">string</span> <tt class="parameter">$filename</tt></span> [, <span class="methodparam"><span class="type">bool</span> <tt class="parameter">$compressionmode</tt></span> [, <span class="methodparam"><span class="type">bool</span> <tt class="parameter">$format</tt></span> ]] )</div> <p class="para rdfs-comment"> Creates an XML document from the dom representation. This function usually is called after building a new dom document from scratch as in the example below. The <i><tt class="parameter">format</tt></i> specifies whether the output should be neatly formatted, or not. The first parameter specifies the name of the filename and the second parameter, whether it should be compressed or not. </p> <p class="para"> <div class="example"> <p><b>Example #1 Creating a simple HTML document header</b></p> <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB"><?php<br />$doc </span><span style="color: #007700">= </span><span style="color: #0000BB">domxml_new_doc</span><span style="color: #007700">(</span><span style="color: #DD0000">"1.0"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$root </span><span style="color: #007700">= </span><span style="color: #0000BB">$doc</span><span style="color: #007700">-></span><span style="color: #0000BB">create_element</span><span style="color: #007700">(</span><span style="color: #DD0000">"HTML"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$root </span><span style="color: #007700">= </span><span style="color: #0000BB">$doc</span><span style="color: #007700">-></span><span style="color: #0000BB">append_child</span><span style="color: #007700">(</span><span style="color: #0000BB">$root</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$head </span><span style="color: #007700">= </span><span style="color: #0000BB">$doc</span><span style="color: #007700">-></span><span style="color: #0000BB">create_element</span><span style="color: #007700">(</span><span style="color: #DD0000">"HEAD"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$head </span><span style="color: #007700">= </span><span style="color: #0000BB">$root</span><span style="color: #007700">-></span><span style="color: #0000BB">append_child</span><span style="color: #007700">(</span><span style="color: #0000BB">$head</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$title </span><span style="color: #007700">= </span><span style="color: #0000BB">$doc</span><span style="color: #007700">-></span><span style="color: #0000BB">create_element</span><span style="color: #007700">(</span><span style="color: #DD0000">"TITLE"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$title </span><span style="color: #007700">= </span><span style="color: #0000BB">$head</span><span style="color: #007700">-></span><span style="color: #0000BB">append_child</span><span style="color: #007700">(</span><span style="color: #0000BB">$title</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$text </span><span style="color: #007700">= </span><span style="color: #0000BB">$doc</span><span style="color: #007700">-></span><span style="color: #0000BB">create_text_node</span><span style="color: #007700">(</span><span style="color: #DD0000">"This is the title"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$text </span><span style="color: #007700">= </span><span style="color: #0000BB">$title</span><span style="color: #007700">-></span><span style="color: #0000BB">append_child</span><span style="color: #007700">(</span><span style="color: #0000BB">$text</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$doc</span><span style="color: #007700">-></span><span style="color: #0000BB">dump_file</span><span style="color: #007700">(</span><span style="color: #DD0000">"/tmp/test.xml"</span><span style="color: #007700">, </span><span style="color: #0000BB">false</span><span style="color: #007700">, </span><span style="color: #0000BB">true</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span></span></code></div> </div> </div> </p> <p class="para"> See also <a href="function.domdocument-dump-mem.html" class="function">domdocument_dump_mem()</a>, and <a href="function.domdocument-html-dump-mem.html" class="function">domdocument_html_dump_mem()</a>. </p> </div> </div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.domdocument-document-element.html">DomDocument->document_element</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.domdocument-dump-mem.html">DomDocument->dump_mem</a></div> <div class="up"><a href="ref.domxml.html">DOM XML Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -