Skip to content

Commit 026d31e

Browse files
committed
Document DOMNode::compareDocumentPosition()
1 parent abcaa69 commit 026d31e

File tree

2 files changed

+99
-1
lines changed

2 files changed

+99
-1
lines changed
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<refentry xml:id="domnode.comparedocumentposition" xmlns="http://docbook.org/ns/docbook">
3+
<refnamediv>
4+
<refname>DOMNode::compareDocumentPosition</refname>
5+
<refpurpose>Compares the position of two nodes</refpurpose>
6+
</refnamediv>
7+
8+
<refsect1 role="description">
9+
&reftitle.description;
10+
<methodsynopsis role="DOMNode">
11+
<modifier>public</modifier> <type>int</type><methodname>DOMNode::compareDocumentPosition</methodname>
12+
<methodparam><type>DOMNode</type><parameter>other</parameter></methodparam>
13+
</methodsynopsis>
14+
<para>
15+
Compares the position of the other node relative to this node.
16+
</para>
17+
</refsect1>
18+
19+
<refsect1 role="parameters">
20+
&reftitle.parameters;
21+
<para>
22+
<variablelist>
23+
<varlistentry>
24+
<term><parameter>other</parameter></term>
25+
<listitem>
26+
<para>
27+
The node for which the position should be compared for, relative to this node.
28+
</para>
29+
</listitem>
30+
</varlistentry>
31+
</variablelist>
32+
</para>
33+
</refsect1>
34+
35+
<refsect1 role="returnvalues">
36+
&reftitle.returnvalues;
37+
<para>
38+
A bitmask of the <link linkend="domnode.constants">DOMNode::DOCUMENT_POSITION_*</link>
39+
constants.
40+
</para>
41+
</refsect1>
42+
43+
<refsect1 role="examples">
44+
&reftitle.examples;
45+
<example>
46+
<title><methodname>DOMNode::compareDocumentPosition</methodname> example</title>
47+
<programlisting role="php">
48+
<![CDATA[
49+
<?php
50+
$xml = <<<XML
51+
<root>
52+
<child1/>
53+
<child2/>
54+
</root>
55+
XML;
56+
57+
$dom = new DOMDocument();
58+
$dom->loadXML($xml);
59+
60+
$root = $dom->documentElement;
61+
$child1 = $root->firstElementChild;
62+
$child2 = $child1->nextElementSibling;
63+
64+
var_dump($root->compareDocumentPosition($child1));
65+
var_dump($child2->compareDocumentPosition($child1));
66+
?>
67+
]]>
68+
</programlisting>
69+
&example.outputs;
70+
<screen>
71+
<![CDATA[
72+
int(20) // This is DOMNode::DOCUMENT_POSITION_CONTAINED_BY | DOMNode::DOCUMENT_POSITION_FOLLOWING
73+
int(2) // This is DOMNode::DOCUMENT_POSITION_PRECEDING
74+
]]>
75+
</screen>
76+
</example>
77+
</refsect1>
78+
</refentry>
79+
<!-- Keep this comment at the end of the file
80+
Local variables:
81+
mode: sgml
82+
sgml-omittag:t
83+
sgml-shorttag:t
84+
sgml-minimize-attributes:nil
85+
sgml-always-quote-attributes:t
86+
sgml-indent-step:1
87+
sgml-indent-data:t
88+
indent-tabs-mode:nil
89+
sgml-parent-document:nil
90+
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
91+
sgml-exposed-tags:nil
92+
sgml-local-catalogs:nil
93+
sgml-local-ecat-files:nil
94+
End:
95+
vim600: syn=xml fen fdm=syntax fdl=2 si
96+
vim: et tw=78 syn=sgml
97+
vi: ts=1 sw=1
98+
-->

reference/dom/versions.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@
145145
<function name="domnode::c14n" from="PHP 5 &gt;= 5.2.0, PHP 7, PHP 8"/>
146146
<function name="domnode::c14nfile" from="PHP 5 &gt;= 5.2.0, PHP 7, PHP 8"/>
147147
<function name="domnode::clonenode" from="PHP 5, PHP 7, PHP 8"/>
148-
<function name="domnode::comparedocumentposition" from="PHP 5, PHP 7"/>
148+
<function name="domnode::comparedocumentposition" from="PHP 8 &gt;= 8.4.0"/>
149149
<function name="domnode::contains" from="PHP 8 &gt;= 8.3.0"/>
150150
<function name="domnode::getfeature" from="PHP 5, PHP 7"/>
151151
<function name="domnode::getlineno" from="PHP 5 &gt;= 5.3.0, PHP 7, PHP 8"/>

0 commit comments

Comments
 (0)