iam_dumb
asked on
PHP and COM
Dear Experts,
I'm trying to develop the COM library with Delphi 7, but I have problems using it in PHP. So far, I have added two COM objects "Domains" (collection) and "Domain". When I launch the simple PHP script below, the exception occurs, and window popups, asking to send the error report to Microsoft.
$domains = new COM("MyLib.Domains");
$domain = $domains->Item(1);
echo $domain->Name;
The ASP analog below, in VBScript works perfect
set Domains = Server.CreateObject("MyLib .Domains")
set Domain = Domains(1)
Response.Write Domain.Name
One interesting thing: when in Delphi I rename property "Domain.Name" to "Domain.DomainName" suddently it starts to work in PHP, but when I start to add other new properties and methods - they fall again.
I have tested it with PHP4.2.1, PHP4.3.2 and PHP5.0.0beta.
Maybe I should take into consideration some important details when I'm developing COM objects with Delphi, or is this is a PHP bug?
TIA,
dumb
I'm trying to develop the COM library with Delphi 7, but I have problems using it in PHP. So far, I have added two COM objects "Domains" (collection) and "Domain". When I launch the simple PHP script below, the exception occurs, and window popups, asking to send the error report to Microsoft.
$domains = new COM("MyLib.Domains");
$domain = $domains->Item(1);
echo $domain->Name;
The ASP analog below, in VBScript works perfect
set Domains = Server.CreateObject("MyLib
set Domain = Domains(1)
Response.Write Domain.Name
One interesting thing: when in Delphi I rename property "Domain.Name" to "Domain.DomainName" suddently it starts to work in PHP, but when I start to add other new properties and methods - they fall again.
I have tested it with PHP4.2.1, PHP4.3.2 and PHP5.0.0beta.
Maybe I should take into consideration some important details when I'm developing COM objects with Delphi, or is this is a PHP bug?
TIA,
dumb
> Delphi arrays are 0-based, so probably
make that PHP arrays...
make that PHP arrays...
ASKER
Nop, didn't help :(
what is the error message that you get?
And which line exactly is causing the exception? Try commenting out the second and third, then only the third...
ASKER
There are no exact error message (I'm on XP), there is only common error popup, that ask to send error report to Microsoft if something is wrong.
The exact line, that causes an error is
echo $domain->Name;
Moreover, if for this property in Delphi I add Debug procedure (Debug is a custom procedure, that just writes the string param to my debug file) like shown below, it never invoke the Debug, so I guess, PHP can't find this property for some reason.
function TDomain.Get_Name: WideString;
begin
Debug('Property Works!');
Result := FDomain.DomainName;
end;
The exact line, that causes an error is
echo $domain->Name;
Moreover, if for this property in Delphi I add Debug procedure (Debug is a custom procedure, that just writes the string param to my debug file) like shown below, it never invoke the Debug, so I guess, PHP can't find this property for some reason.
function TDomain.Get_Name: WideString;
begin
Debug('Property Works!');
Result := FDomain.DomainName;
end;
What is the value of
$domains->Item->Count();
And what about
$domain = $domains->Item[0];
or
$domain = $domains->Domain[0];
$domains->Item->Count();
And what about
$domain = $domains->Item[0];
or
$domain = $domains->Domain[0];
ASKER
echo $domains->Item->Count()
raises an exception
echo $domains->Item->Count
raises an exception
echo $domains->Count
returns the valid number of domains
$domain = $domains->Item[0];
raises an exception
$domain = $domains->Item[0];
raises an exception
$domain = $domains->Domain[0];
raises an exception
$domain = $domains->Item(1);
works
raises an exception
echo $domains->Item->Count
raises an exception
echo $domains->Count
returns the valid number of domains
$domain = $domains->Item[0];
raises an exception
$domain = $domains->Item[0];
raises an exception
$domain = $domains->Domain[0];
raises an exception
$domain = $domains->Item(1);
works
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
$domain = $domains->Item(1);
should become
$domain = $domains->Item(0);