4

I'm using xampp.

I search and it looks like for php 4.x, there was an extension called php_w32api.dll which seems to have vanished for php 5.x. Nevertheless, it's still in the documentation on php.net but marked as experimental.

Some suggested to use win32std in pecl instead, but that just wraps some function of the win32 api, but doesn't allow me do call my own dll functions. :/

There is ffi, but the link on the pecl site is dead and it seems like development has stopped in 2004.

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

Best regards Marc

4

1 回答 1

4

COM 函数仅适用于 Windows 版本的 PHP。.Net 支持需要 PHP 5 和 .Net 运行时。无需安装即可使用这些功能;它们是 PHP 核心的一部分。

首先创建您的 ActiveX dll (Visual Basic):将您的项目命名为“foo”,将类命名为“bar”。

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

然后制作 dll 并将其注册到 regsvr32.exe 现在创建您的 PHP 脚本:

 <?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!)
    ?>
于 2009-12-23T21:35:49.833 回答