note 45038 modified in ref.com by danbrown

From: Date: Mon, 21 Dec 2009 17:10:04 +0000
Subject: note 45038 modified in ref.com by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-164211@lists.php.net to get a copy of this message
To pass a parameter by reference to a COM function, you need to pass VARIANT to it. Common data types like integers and strings will not work for it. As an example, calling a function that retrieves the name of a person will look like: <?php $Name = new VARIANT; $comobj = new COM("MyCOMOBj.Component") or die("Couldn't create the COM Component"); if(!$comobj->GetName($Name)) { echo("Could not retrieve name"); } else { echo("The name retrieved is : " . $Name->value); } ?> $Name->type will contain the type of the value stored in the VARIANT e.g. VT_BSTR. Note For PHP 5: Insted of '$Name->value', we can use only '$Name' for getting the value stored in the VARIANT. To get the type of the value stored in the VARIANT, use 'variant_get_type($Name)'. Feroz Zahid --was-- To pass a parameter by reference to a COM function, you need to pass VARIANT to it. Common data types like integers and strings will not work for it. As an example, calling a function that retrieves the name of a person will look like: $Name = new VARIANT; $comobj = new COM("MyCOMOBj.Component") or die("Couldn't create the COM Component"); if(!$comobj->GetName($Name)) { echo("Could not retrieve name"); } else { echo("The name retrieved is : " . $Name->value); } $Name->type will contain the type of the value stored in the VARIANT e.g. VT_BSTR. Note For PHP 5: Insted of '$Name->value', we can use only '$Name' for getting the value stored in the VARIANT. To get the type of the value stored in the VARIANT, use 'variant_get_type($Name)'. Feroz Zahid http://php.net/manual/en/ref.com.php

« previous php.notes (#164211) next »