ConFoo Montreal 2026: Call for Papers

Voting

: five minus three?
(Example: nine)

The Note You're Voting On

php at racinghippo dot co dot uk
22 years ago
PASSING/RETURNING PARAMETERS BY REFERENCE
=========================================

Some COM functions not only return values through the return value, but also act upon a variable passed to it as a parameter *By Reference*:

RetVal = DoSomethingTo (myVariable)

Simply sticking an '&' in front of myVariable doesn't work - you need to pass it a variant of the correct type, as follows:

$myStringVariant = new VARIANT("over-write me", VT_BSTR);
$result = $comobj->DoSomethingTo( &$myStringVariant );

The value in the variant can then be retrieved by:

$theActualValue = $myStringVariant->value;

Other types of variant can be created as your needs demand - see the preceding section on the VARIANT type.

<< Back to user notes page

To Top