<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/book.com.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'en',
  ),
  'this' => 
  array (
    0 => 'class.variant.php',
    1 => 'variant',
    2 => 'variant class',
  ),
  'up' => 
  array (
    0 => 'book.com.php',
    1 => 'COM',
  ),
  'prev' => 
  array (
    0 => 'dotnet.construct.php',
    1 => 'dotnet::__construct',
  ),
  'next' => 
  array (
    0 => 'variant.construct.php',
    1 => 'variant::__construct',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/com/variant.xml',
  ),
  'history' => 
  array (
  ),
  'extra_header_links' => 
  array (
    'rel' => 'alternate',
    'href' => '/manual/en/feeds/class.variant.atom',
    'type' => 'application/atom+xml',
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="class.variant" class="reference">
 
 <h1 class="title">variant class</h1>
 <div class="partintro"><p class="verinfo">(PHP 4 &gt;= 4.1.0, PHP 5, PHP 7, PHP 8)</p>


  <div class="section" id="variant.intro">
   <h2 class="title">Introduction</h2>
   <p class="para">
    The VARIANT is COM&#039;s equivalent of the PHP zval; it is a structure that
    can contain a value with a range of different possible types.  The variant
    class provided by the COM extension allows you to have more control over
    the way that PHP passes values to and from COM.
   </p>
  </div>


  <div class="section" id="variant.synopsis">
   <h2 class="title">Class synopsis</h2>


   <div class="classsynopsis"><div class="classsynopsisinfo">
    
     <span class="modifier">class</span> <strong class="classname"><strong class="classname">variant</strong></strong>
     {</div>

    <div class="classsynopsisinfo classsynopsisinfo_comment">/* Methods */</div>
    <div class="constructorsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><a href="variant.construct.php" class="methodname">__construct</a></span>(<span class="methodparam"><span class="type"><a href="language.types.mixed.php" class="type mixed">mixed</a></span> <code class="parameter">$value</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>, <span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$type</code><span class="initializer"> = <strong><code><a href="com.constants.php#constant.vt-empty">VT_EMPTY</a></code></strong></span></span>, <span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$codepage</code><span class="initializer"> = <strong><code><a href="com.constants.php#constant.cp-acp">CP_ACP</a></code></strong></span></span>)</div>

   }</div>


  </div>

  <div class="section" id="class.variant.examples">
   <h2 class="title">variant examples</h2>
   <p class="para">
    <div class="example" id="com.variant.example.php5">
     <p><strong>Example #1 variant example</strong></p>
     <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$v </span><span style="color: #007700">= new </span><span style="color: #0000BB">variant</span><span style="color: #007700">(</span><span style="color: #0000BB">42</span><span style="color: #007700">);<br />print </span><span style="color: #DD0000">"The type is " </span><span style="color: #007700">. </span><span style="color: #0000BB">variant_get_type</span><span style="color: #007700">(</span><span style="color: #0000BB">$v</span><span style="color: #007700">) . </span><span style="color: #DD0000">"&lt;br/&gt;"</span><span style="color: #007700">;<br />print </span><span style="color: #DD0000">"The value is " </span><span style="color: #007700">. </span><span style="color: #0000BB">$v </span><span style="color: #007700">. </span><span style="color: #DD0000">"&lt;br/&gt;"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
     </div>

    </div>
   </p>
   <blockquote class="note"><p><strong class="note">Note</strong>: 
    <p class="para">
     When returning
     a value or fetching a variant property, the variant is converted to a PHP
     value only when there is a direct mapping between the types that would
     not result in a loss of information.  In all other cases, the result is
     returned as an instance of the variant class.  You can force PHP to
     convert or evaluate the variant as a PHP native type by using a casting
     operator explicitly, or implicitly casting to a string by
     <span class="function"><a href="function.print.php" class="function">print</a></span>ing it.  You may use the wide range of variant
     functions to perform arithmetic operations on variants without forcing a
     conversion or risking a loss of data.
    </p>
   </p></blockquote>
   <p class="para">
    See also <span class="function"><a href="function.variant-get-type.php" class="function">variant_get_type()</a></span>.
   </p>
  </div>

 </div>

 





<h2>Table of Contents</h2><ul class="chunklist chunklist_reference"><li><a href="variant.construct.php">variant::__construct</a> — variant class constructor</li></ul>
</div>
<?php manual_footer($setup); ?>