Re: Using DLL with PHP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Feb 10, 2009 at 11:59 AM, Dan Shirah <mrsquash2@xxxxxxxxx> wrote:
> Alrighty, so I went a different route...
>
> I created my own ActiveX DLL...one that I know I can register.
>
> Starting out really simple:
>
> //My VB code
> Public Function hello() As String
>
>     hello = "Hello World!"
> End Function
>
> //My PHP code
> <?php
> function Hello() {
> $new_com = new COM("DMStoTIFF.conv");
> $output=$new_com->hello();
> echo $output;}
> Hello();
> ?>
>
> So, after I register the DLL on the server my PHP page is correctly
> displaying the "Hello World!" dialog.
>
> What I'm having problems with now is trying to pass a variable to the DLL.
>
> Shouldn't I be able to do this just like any other PHP class/function?

Generally I think you can. You may run into issues where the function
parameters and return values must be defined as variants in your DLL,
or you may need to cast your PHP variables into instances of the
VARIANT class.

In ASP I mostly used the Scripting.Dictionary (like a hash table, I
guess, since arrays in VBScript are all integer-indexed),
Scripting.FileSystemObject, the ADODB library for database access, and
sometimes a utility to manipulate images, process file uploads, or
file compression. PHP already has extensions for all of these, so I
haven't had to delve into the complexity of using COM in PHP.

Just for kicks, I just tried this in Zend Studio which is running PHP
5.2.0 under WinXP, and it worked as expected:

<?php

$some_file = '';  // PATH TO SOME FILE

$x = new COM('Scripting.FileSystemObject');

if ($x->FileExists($some_file)) {
    echo 'The file exists!';
} else {
    echo 'The file does not exist.';
}

?>

Andrew

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux