如何从windows的php中的dll调用函数? [英] How do I call a function from a dll from php on windows?

查看:179
本文介绍了如何从windows的php中的dll调用函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用xampp。

I'm using xampp.

我搜索,它看起来像PHP 4.x,有一个名为php_w32api.dll的扩展,似乎已经消失php 5.x.然而,它仍然在php.net的文档中,但标记为实验。

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.

有些建议使用pecl中的win32std,但只是包装了一些win32 api的功能,但是不允许我打电话给我自己的dll函数。 :/

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. :/

有ffi,但pecl网站上的链接已经死了,似乎2004年发展停止了。

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

任何想法如何做,而不需要自己的PHP扩展名?

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

最好的问候
Marc

Best regards Marc

推荐答案

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

COM functions are only available for the Windows version of PHP. .Net support requires PHP 5 and the .Net runtime. No installation needed to use these functions; they are part of the PHP core.

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

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

然后make 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!)
    ?>

这篇关于如何从windows的php中的dll调用函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆