Developer on Alibaba Coud: Build your first app with APIs, SDKs, and tutorials on the Alibaba Cloud. Read more ＞
After calling JavaBean in PHP4 and trying to call COM, I thought it was very difficult. I wrote an Active Dll using VB6 and called it in PHP4 immediately, it is much more convenient than calling javabean. The following describes my steps.
I. Use VB6 to write Activex Dll
The code is as follows:
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
Public Sub OnEndPage ()
Set MyScriptingContext = Nothing
Set MyApplication = Nothing
Set MyRequest = Nothing
Set MyResponse = Nothing
Set MyServer = Nothing
Set MySession = Nothing
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
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
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 );
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 ".
If you are interested, please contact us.
This article is an English version of an article which is originally in the Chinese language on aliyun.com and is provided for information purposes only. This website makes no representation or warranty of any kind, either expressed or implied, as to the accuracy, completeness ownership or
reliability of the article or any translations thereof. If you have any concerns or complaints relating to the article, please send an email, providing a detailed description of the concern or
complaint, to firstname.lastname@example.org. A staff member will contact you within 5 working days. Once verified, infringing content will be removed immediately.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
and provide relevant evidence. A staff member will contact you within 5 working days.