Home > Backend Development > PHP Tutorial > PHP4 calls COM components written by yourself_PHP tutorial

PHP4 calls COM components written by yourself_PHP tutorial

WBOY
Release: 2016-07-20 11:04:06
Original
765 people have browsed it

Author: Dongfang Yishe
After finishing PHP4 calling JavaBean, I wanted to try calling COM again. I thought it was difficult at first. I wrote an Active Dll in VB6 and called it in PHP4. It succeeded immediately. It is much more convenient than calling JavaBean. Here are my steps.
The downloaded version is from http://www.mm4.de/.
One: 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 new VB6 project, and ActiveX Dll will The project is named P_test, and the class name is c_test
. The file content of the class is as above.
Compile and generate the p_test.dll file
Two: Register and run at the
prompt: regsvr32 p_test.dll
Third: Write the php file, the test.php4 code is as follows:

$b=new COM("p_test.c_test");
$a=$b->Test_Number(-454);
echo $a;
?>
Run php4 file -1 will be displayed
The problem you may encounter is that the project cannot be compiled. You need to reference the
Microsoft Active Server Pages Object Library
and implement "Project->References" to find the modified library. And check
In comparison, PHP4 calling com should be better than PHP4 calling javabean, because it is Ms system after all. You can also write your own controls for calling the database and use PHP4 to call them. To a certain extent, it is the same as PHP calling javabeans. It can be said that "hidden source code" is achieved.
This article comes from:

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/445244.htmlTechArticleAuthor: Dongfang Yishe finished calling JavaBean in PHP4, and wanted to try calling COM. I thought it was difficult at first. I wrote an Active Dll using VB6 and called it in PHP4. It was successful immediately, which is better than calling java...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template