Php 必须调用COM对象方法一次才能在函数内部使用
我正在学习如何在PHP中使用COM对象和DLL,我遇到了一些看起来不太正确的东西。这项工作:Php 必须调用COM对象方法一次才能在函数内部使用,php,com,Php,Com,我正在学习如何在PHP中使用COM对象和DLL,我遇到了一些看起来不太正确的东西。这项工作: $comobj = new COM("COMLoggerClass"); echo 'here1'; $comobj->Log('test1'); echo 'here2'; function test($pComObj) { echo 'here4'; $pComObj->Log('test2'); echo 'here5'; } echo 'here3'; t
$comobj = new COM("COMLoggerClass");
echo 'here1';
$comobj->Log('test1');
echo 'here2';
function test($pComObj)
{
echo 'here4';
$pComObj->Log('test2');
echo 'here5';
}
echo 'here3';
test($comobj);
这并不是:
$comobj = new COM("COMLoggerClass");
echo 'here1';
//$comobj->Log('test1');
echo 'here2';
function test($pComObj)
{
echo 'here4';
$pComObj->Log('test2');
echo 'here5';
}
echo 'here3';
test($comobj);
第二个错误导致行$pComObj->Log('test2')上出现致命错误代码>显示此消息:
Cannot pass parameter 1 by reference
因此,本质上,在这种情况下,COM对象的方法必须在创建对象的范围内使用一次,然后才能在方法中使用。但这没有任何意义。这到底是怎么回事