How do I call a function from a dll from php on windows?

I am using xampp.

I am looking, and it looks like php 4.x, there was a php_w32api.dll extension that seems to have disappeared for php 5.x. However, it is still in the documentation at php.net, but marked as experimental.

Some have suggested using win32std in pecl instead, but it just wraps some win32 api function, but doesnโ€™t allow me to call my own dll.:/ functions

There is ffi, but the link to the pecl site is dead, and it looks like the process stopped in 2004.

Any idea how to do this without writing my own php extension?

Regards Mark

+4
source share
1 answer

COM functions are only available for the PHP version of Windows. .Net requires PHP 5 and the .NET environment. No installation is required to use these features; they are part of the core of PHP.

First create your ActiveX (Visual Basic) DLL: Name your project as "foo" and class as "bar".

'---start VB code--- Public Function hello() As String hello = "Hello World!" End Function '---end VB code--- 

Then create a dll and register it with regsvr32.exe. Now create your PHP script:

  <?php $obj = new COM("foo.bar"); $output=$obj->hello(); // Call the "hello()" method // once we created the COM object this can be used like any other php classes. echo $output; // Displays Hello World! (so this comes from the dll!) ?> 
+4
source

All Articles