Home > Backend Development > PHP Tutorial > PHP4 calls self-written COM components_PHP tutorial

PHP4 calls self-written COM components_PHP tutorial

WBOY
Release: 2016-07-13 17:24:56
Original
786 people have browsed it

After finishing calling JavaBean in PHP4, I wanted to try calling COM. 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. Let me talk about my steps below.
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 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, ActiveX Dll Name the project P_test and the class name 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;
?>
Running the php4 file will show - 1
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.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/532093.htmlTechArticleAfter finishing calling JavaBean in PHP4, I wanted to try calling COM. I thought it was difficult at first, so I wrote it in VB6. An Active Dll is called in PHP4 and it succeeds immediately. It is much more convenient than calling javabean. Below...
Related labels:
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