首页 >> 民生教育

如何用PHP调用自己编写的COM组件节能

民生教育  2020-11-11 03:28 字号: 大 中 小

首先写ActiveX Dll:

新建一个VB6工程,ActiveX Dll将工程命名为P_test,类名为c_test ,类的文件内容如下:Option Explicit

Private MyScriptingContext As ScriptingContext

Private MyApplication As Application

Privat实际上e MyRequest As Request Private MyResponse As Response

Private MyServer As Server

Private MySession As Session Public

Sub OnStartPage(PassedScriptingContext As ScriptingContext)

Set MyScriptingContext = PassedScriptingContext

Set MyApplication = plication

Set MyRequest = quest

Set MyResponse = sponse

Set MyServer = rver

Set MySession = ssion

End Sub

Public Sub OnEndPage()

Set MyScriptingContext = Nothing

Set MyApplication = Nothing

Set MyRequest = Nothing<出现明显的增长特性/p>

Set MyResponse = Nothing

Set MyServer = Nothing

Set MySession = Nothing

End Sub

Public Function Test_Number(num) As Variant

If num 0 Then Get_Number_Attrib = -1

If num 0 Then Get_Number_Attrib = 1

If num = 0 Then Get_Number_Attrib = 0

End Function

编译生成p_l文件

注册

提示符下运行:regsvr32 p_l

编写php文件,p4代码如下:

<?

$b=new COM("p_test.c_test");

$a=$b->Test_Number(-454);

echo $a;

?>

可能遇到的问题是,编译工程时通不过,要将

Microsoft Active Server Pages Object Library

引用进来,具体实现"Project-References"找到改库,并勾上 。

碧凯保妇康栓预防宫颈癌吗
常州白癜风医院哪个较好
南通哪里专业治白癜风
推荐资讯