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

☆樱花仙子☆ 提交于 2019-12-03 08:41:09

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.

First create your ActiveX dll (Visual Basic): 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 make the 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!)
    ?>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!