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

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

68
105
<refsect1 role="examples">
69
106
&reftitle.examples;
70
107
<para>
...
...
@@ -83,30 +120,6 @@ echo $doc->saveHTML();
83
120
</para>
84
121
</refsect1>
85
122

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

122
134
<!-- Keep this comment at the end of the file
123
135
Local variables:
124
136
mode: sgml
125
137