reference/com/variant.xml
14767af0f05dffa6fdb9b49e1a1f4e9ca7022a60
...
...
@@ -1,135 +1,80 @@
1
1
<?xml version="1.0" encoding="utf-8"?>
2
2
<!-- $Revision$ -->
3
-
<phpdoc:classref xmlns:phpdoc="http://php.net/ns/phpdoc" xml:id="class.variant" xmlns="http://docbook.org/ns/docbook">
4
-
<titleabbrev>VARIANT</titleabbrev>
5
-
<title>VARIANT class</title>
3
+
<phpdoc:classref xml:id="class.variant" xmlns:phpdoc="http://php.net/ns/phpdoc" xmlns="http://docbook.org/ns/docbook" xmlns:xi="http://www.w3.org/2001/XInclude">
4
+
<titleabbrev>variant</titleabbrev>
5
+
<title>variant class</title>
6
6
<partintro>
7
7

8
-
<section xml:id="class.variant.class">
9
-
<title>Description</title>
10
-
<simpara>
11
-
The VARIANT is COM's equivalent of the PHP zval; it is a structure that
12
-
can contain a value with a range of different possible types. The VARIANT
13
-
class provided by the COM extension allows you to have more control over
14
-
the way that PHP passes values to and from COM.
15
-
</simpara>
16
-
<simpara>
17
-
<literal>$vVar = new VARIANT($var)</literal>
18
-
</simpara>
19
-
</section>
20
-
<section xml:id="variant.variant">
21
-
<title>Methods</title>
22
-
<methodsynopsis>
23
-
<methodname>VARIANT::VARIANT</methodname>
24
-
<methodparam choice="opt"><type>mixed</type><parameter>value</parameter></methodparam>
25
-
<methodparam choice="opt"><type>int</type><parameter>type</parameter></methodparam>
26
-
<methodparam choice="opt"><type>int</type><parameter>codepage</parameter></methodparam>
27
-
</methodsynopsis>
28
-
<para>
29
-
VARIANT class constructor. Parameters:
30
-
<variablelist>
31
-
<varlistentry><term>value</term>
32
-
<listitem>
33
-
<simpara>
34
-
initial value. if omitted, or set to &null; an VT_EMPTY object is created.
35
-
</simpara>
36
-
</listitem>
37
-
</varlistentry>
38
-
<varlistentry><term>type</term>
39
-
<listitem>
40
-
<simpara>
41
-
specifies the content type of the VARIANT object. Possible values are
42
-
one of the <constant>VT_XXX</constant> <xref
43
-
linkend="com.constants"/>.
44
-
</simpara>
45
-
<simpara>
46
-
In PHP versions prior to PHP 5, you could force PHP to pass a variant
47
-
object by reference by OR'ing <constant>VT_BYREF</constant>
48
-
with the <parameter>type</parameter>. In PHP 5, this hack is not
49
-
supported; instead, PHP 5 can detect parameters passed by reference
50
-
automatically; they do not even need to be passed as VARIANT objects.
51
-
</simpara>
52
-
<simpara>
53
-
Consult the <acronym>MSDN</acronym> library for additional information
54
-
on the VARIANT type.
55
-
</simpara>
56
-
</listitem>
57
-
</varlistentry>
58
-
<varlistentry><term>codepage</term>
59
-
<listitem>
60
-
<simpara>
61
-
specifies the codepage that is used to convert strings to
62
-
unicode. See the parameter of the same name in the
63
-
<xref linkend="class.com"/> class for more information.
64
-
</simpara>
65
-
</listitem>
66
-
</varlistentry>
67
-
</variablelist>
68
-
</para>
69
-
<para>
70
-
PHP versions prior to PHP 5 define a number of (undocumented) virtual properties
71
-
for instances of the VARIANT class; these properties have all been removed in
72
-
PHP 5 in favour of its more natural syntax; these differences are best
73
-
highlighted by example:
74
-
</para>
75
-
<para>
76
-
<example xml:id="com.variant.example.php4">
77
-
<title>Variant example, PHP 4.x style</title>
78
-
<programlisting role="php">
79
-
<![CDATA[
80
-
<?php
81
-
$v = new VARIANT(42);
82
-
print "The type is " . $v->type . "<br/>";
83
-
print "The value is " . $v->value . "<br/>";
84
-
?>
85
-
]]>
86
-
</programlisting>
87
-
</example>
88
-
</para>
89
-
<para>
90
-
<example xml:id="com.variant.example.php5">
91
-
<title>Variant example, PHP 5 style</title>
92
-
<programlisting role="php">
8
+
<!-- {{{ variant intro -->
9
+
<section xml:id="variant.intro">
10
+
&reftitle.intro;
11
+
<para>
12
+
The VARIANT is COM's equivalent of the PHP zval; it is a structure that
13
+
can contain a value with a range of different possible types. The variant
14
+
class provided by the COM extension allows you to have more control over
15
+
the way that PHP passes values to and from COM.
16
+
</para>
17
+
</section>
18
+
<!-- }}} -->
19
+

20
+
<section xml:id="variant.synopsis">
21
+
&reftitle.classsynopsis;
22
+

23
+
<!-- {{{ Synopsis -->
24
+
<classsynopsis class="class">
25
+
<ooclass>
26
+
<classname>variant</classname>
27
+
</ooclass>
28
+

29
+
<classsynopsisinfo role="comment">&Methods;</classsynopsisinfo>
30
+
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.variant')/db:refentry/db:refsect1[@role='description']/descendant::db:constructorsynopsis[@role='variant'])">
31
+
<xi:fallback/>
32
+
</xi:include>
33
+
</classsynopsis>
34
+
<!-- }}} -->
35
+

36
+
</section>
37
+

38
+
<section xml:id="class.variant.examples">
39
+
<title>variant examples</title>
40
+
<para>
41
+
<example xml:id="com.variant.example.php5">
42
+
<title>variant example</title>
43
+
<programlisting role="php">
93
44
<![CDATA[
94
45
<?php
95
-
$v = new VARIANT(42);
46
+
$v = new variant(42);
96
47
print "The type is " . variant_get_type($v) . "<br/>";
97
48
print "The value is " . $v . "<br/>";
98
49
?>
99
50
]]>
100
-
</programlisting>
101
-
</example>
102
-
</para>
103
-
<para>
104
-
The reason for the change is that, internally, the COM extension sees
105
-
VARIANT, COM and DOTNET classes as the same thing, and the design
106
-
philosophy for these classes is that all property and member accesses are
107
-
passed through to COM with no interference. The new syntax is more
108
-
natural and less effort, and most of the removed virtual properties didn't
109
-
make any sense in a PHP context in any case.
110
-
</para>
111
-
<note>
51
+
</programlisting>
52
+
</example>
53
+
</para>
54
+
<note>
55
+
<para>
56
+
When returning
57
+
a value or fetching a variant property, the variant is converted to a PHP
58
+
value only when there is a direct mapping between the types that would
59
+
not result in a loss of information. In all other cases, the result is
60
+
returned as an instance of the variant class. You can force PHP to
61
+
convert or evaluate the variant as a PHP native type by using a casting
62
+
operator explicitly, or implicitly casting to a string by
63
+
<function>print</function>ing it. You may use the wide range of variant
64
+
functions to perform arithmetic operations on variants without forcing a
65
+
conversion or risking a loss of data.
66
+
</para>
67
+
</note>
112
68
<para>
113
-
PHP 5 takes a much simpler approach to handling VARIANTs; when returning
114
-
a value or fetching a variant property, the variant is converted to a PHP
115
-
value only when there is a direct mapping between the types that would
116
-
not result in a loss of information. In all other cases, the result is
117
-
returned as an instance of the VARIANT class. You can force PHP to
118
-
convert or evaluate the variant as a PHP native type by using a casting
119
-
operator explicitly, or implicitly casting to a string by
120
-
<function>print</function>ing it. You may use the wide range of variant
121
-
functions to perform arithmetic operations on variants without forcing a
122
-
conversion or risking a loss of data.
69
+
See also <function>variant_get_type</function>.
123
70
</para>
124
-
</note>
125
-
<para>
126
-
See also <function>variant_get_type</function>.
127
-
</para>
128
-
</section>
71
+
</section>
129
72

130
73
</partintro>
131
-
</phpdoc:classref>
132
74

75
+
&reference.com.entities.variant;
76
+

77
+
</phpdoc:classref>
133
78
<!-- Keep this comment at the end of the file
134
79
Local variables:
135
80
mode: sgml
136
81