PHP4 calls the self-developed COM component. After calling JavaBean in PHP4 and trying to call COM, I thought it was very difficult. I wrote an ActiveDll in VB6 and called it in PHP4. it was more convenient than calling javabean, the following describes how to call JavaBean in PHP4 and try to call COM. at first, I thought it was very difficult. I wrote an Active Dll in PHP4 using VB6 and called it immediately, it is much more convenient than calling javabean. The following describes my steps.
The downloaded version is http://www.mm4.de /.
I. use VB6 to write Activex Dll
The code is as follows:
Option Explicit
Private MyScriptingContext As ScriptingContext
Private MyApplication As Application
Private 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 = MyScriptingContext. Application
Set MyRequest = MyScriptingContext. Request
Set MyResponse = MyScriptingContext. Response
Set MyServer = MyScriptingContext. Server
Set MySession = MyScriptingContext. Session
End Sub
Public Sub OnEndPage ()
Set MyScriptingContext = Nothing
Set MyApplication = Nothing
Set MyRequest = Nothing
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
The specific method is as follows: Create a VB6 project, ActiveX Dll name the project P_test, class name c_test
Class file content as above.
Compile and generate the p_test.dll file
II. Registration
Run: regsvr32 p_test.dll
3. Compile the php file. the test. php4 code is as follows:
$ B = new COM ("p_test.c_test ");
$ A = $ B-> Test_Number (-454 );
Echo $;
?>
Running the php4 file will display-1
The possible problem is that when compiling the project
Microsoft Active Server Pages Object Library
Reference. find and modify the library for "Project-> References" and check
In contrast, PHP4 calls com better than PHP4 calls javabean, because it is a Ms system after all. You can also compile the control for calling the database by yourself and call it with PHP4. To some extent, it is the same as calling the javabean with PHP, and it can be said that the "hidden Source Code" is implemented ".
The callback Dll is called in PHP4 immediately, which is much easier than calling javabean. below...