hi, there is a COM function having the following definition (.NET Interop):
public virtual new void CALL(System.String SubroutineName, @params);
in C#.NET, i am able to use the function by....
string param1 = "", param2 = "", param3 = "";
Object[] callParams = {param1, param2, param3};
comobj.Call("called.sub", ref callParams);
i tried the similar things in PHP....
$param1 = ""
$param2 = ""
$param3 = ""
$callParams = array($param1, $param2, $param3);
$comobj->Call("called.sub", $callParams); // how do i set up the by ref passing?
i got error when opening up the page:
PHP Warning: (null)(): Invoke() failed: Exception occurred.\r\n <b>Source</b>: OBjEX.jConnectObject.33 <b>Description</b>: Method : Call : OBJEX.GET.LIST.SUB\r\n\r\nThe subroutine was terminated abnormally.
is it an error from PHP? or from COM?
parameter passing by ref to a COM function
Moderator: General Moderators
-
alanchinese
- Forum Newbie
- Posts: 11
- Joined: Fri Jun 11, 2004 4:53 pm
passing by ref is done in php like this:
Code: Select all
somefunc($by_val, &$by_ref); // note the ampersand-
alanchinese
- Forum Newbie
- Posts: 11
- Joined: Fri Jun 11, 2004 4:53 pm
It does mean I was wrong.PHP Manual wrote: Starting with PHP 5, PHP will automatically detect methods that accept parameters by reference, and will automatically convert regular PHP variables to a form that can be passed by reference. This means that you can call the method very naturally; you needn't go to any extra effort in your code.
In PHP 4, to pass parameters by reference you need to create an instance of the VARIANT class to wrap the byref parameters.