reference/dom/domdocument/loadhtmlfile.xml
4ef716f8aa753e1189b2e57c91da378b16d970b0
...
...
@@ -9,7 +9,7 @@
9
9
</refnamediv>
10
10
<refsect1 role="description">
11
11
&reftitle.description;
12
-
<methodsynopsis>
12
+
<methodsynopsis role="DOMDocument">
13
13
<modifier>public</modifier> <type>bool</type><methodname>DOMDocument::loadHTMLFile</methodname>
14
14
<methodparam><type>string</type><parameter>filename</parameter></methodparam>
15
15
<methodparam choice="opt"><type>int</type><parameter>options</parameter><initializer>0</initializer></methodparam>
...
...
@@ -17,8 +17,24 @@
17
17
<para>
18
18
The function parses the HTML document in the file named
19
19
<parameter>filename</parameter>. Unlike loading XML, HTML does not have
20
-
to be well-formed to load.
20
+
to be well-formed to load.
21
21
</para>
22
+
<warning>
23
+
<para>
24
+
This function parses the input using an HTML 4 parser. The parsing rules
25
+
of HTML 5, which is what modern web browsers use, are different. Depending
26
+
on the input this might result in a different DOM structure. Therefore
27
+
this function cannot be safely used for sanitizing HTML.
28
+
</para>
29
+
<para>
30
+
As an example, some HTML elements will implicitly close a parent element
31
+
when encountered. The rules for automatically closing parent elements
32
+
differ between HTML 4 and HTML 5 and thus the resulting DOM structure that
33
+
<classname>DOMDocument</classname> sees might be different from the DOM
34
+
structure a web browser sees, possibly allowing an attacker to break the
35
+
resulting HTML.
36
+
</para>
37
+
</warning>
22
38
</refsect1>
23
39
<refsect1 role="parameters">
24
40
&reftitle.parameters;
...
...
@@ -35,11 +51,7 @@
35
51
<varlistentry>
36
52
<term><parameter>options</parameter></term>
37
53
<listitem>
38
-
<para>
39
-
Since PHP 5.4.0 and Libxml 2.6.0, you may also use the
40
-
<parameter>options</parameter> parameter to specify <link
41
-
linkend="libxml.constants">additional Libxml parameters</link>.
42
-
</para>
54
+
&dom.parameter.options;
43
55
</listitem>
44
56
</varlistentry>
45
57
</variablelist>
...
...
@@ -48,8 +60,7 @@
48
60
<refsect1 role="returnvalues">
49
61
&reftitle.returnvalues;
50
62
<para>
51
-
&return.success; If called statically, returns a
52
-
<classname>DOMDocument</classname>&return.falseforfailure;.
63
+
&return.success;
53
64
</para>
54
65
</refsect1>
55
66
<refsect1 role="errors">
...
...
@@ -57,13 +68,42 @@
57
68
<para>
58
69
If an empty string is passed as the <parameter>filename</parameter>
59
70
or an empty file is named, a warning will be generated. This warning
60
-
is not generated by libxml and cannot be handled using <link
61
-
linkend="function.libxml-use-internal-errors">libxml's error handling
71
+
is not generated by libxml and cannot be handled using <link linkend="function.libxml-use-internal-errors">libxml's error handling
62
72
functions</link>.
63
73
</para>
64
-
&dom.allowstatic;
65
74
&dom.malformederror;
66
75
</refsect1>
76
+

77
+
<refsect1 role="changelog">
78
+
&reftitle.changelog;
79
+
<informaltable>
80
+
<tgroup cols="2">
81
+
<thead>
82
+
<row>
83
+
<entry>&Version;</entry>
84
+
<entry>&Description;</entry>
85
+
</row>
86
+
</thead>
87
+
<tbody>
88
+
<row>
89
+
<entry>8.3.0</entry>
90
+
<entry>
91
+
This function now has a tentative <type>bool</type> return type.
92
+
</entry>
93
+
</row>
94
+
<row>
95
+
<entry>8.0.0</entry>
96
+
<entry>
97
+
Calling this function statically will
98
+
now throw an <classname>Error</classname>.
99
+
Previously, an <constant>E_DEPRECATED</constant> was raised.
100
+
</entry>
101
+
</row>
102
+
</tbody>
103
+
</tgroup>
104
+
</informaltable>
105
+
</refsect1>
106
+

67
107
<refsect1 role="examples">
68
108
&reftitle.examples;
69
109
<para>
...
...
@@ -82,30 +122,6 @@ echo $doc->saveHTML();
82
122
</para>
83
123
</refsect1>
84
124

85
-
<refsect1 role="changelog">
86
-
&reftitle.changelog;
87
-
<para>
88
-
<informaltable>
89
-
<tgroup cols="2">
90
-
<thead>
91
-
<row>
92
-
<entry>&Version;</entry>
93
-
<entry>&Description;</entry>
94
-
</row>
95
-
</thead>
96
-
<tbody>
97
-
<row>
98
-
<entry>5.4.0</entry>
99
-
<entry>
100
-
Added <parameter>options</parameter> parameter.
101
-
</entry>
102
-
</row>
103
-
</tbody>
104
-
</tgroup>
105
-
</informaltable>
106
-
</para>
107
-
</refsect1>
108
-
109
125
<refsect1 role="seealso">
110
126
&reftitle.seealso;
111
127
<para>
...
...
@@ -117,7 +133,6 @@ echo $doc->saveHTML();
117
133
</para>
118
134
</refsect1>
119
135
</refentry>
120
-

121
136
<!-- Keep this comment at the end of the file
122
137
Local variables:
123
138
mode: sgml
124
139