我正在使用 xampp。
我搜索了一下,它看起来像 php 4.x,有一个名为 php_w32api.dll 的扩展,它似乎在 php 5.x 中消失了。尽管如此,它仍然在 php.net 的文档中,但被标记为实验性的。
有些人建议在 pecl 中使用 win32std,但这只是包装了 win32 api 的一些功能,但不允许我调用我自己的 dll 函数。 :/
有 ffi,但 pecl 站点上的链接已失效,开发似乎已在 2004 年停止。
知道如何在不编写我自己的 php 扩展的情况下做到这一点吗?
最好的问候 马克
最佳答案
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!)
?>
关于php - 如何在 Windows 上从 php 的 dll 中调用函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1955429/