After completing the PHP4 call Javabean, I want to try to call COM, start thinking hard, I wrote an Active DLL with VB6 in PHP4, it is more convenient to call Javabean, let's talk about my step below.
One: Write ActiveX DLL with VB6
code show as below:
Option expedition
Private myscriptingContext as scriptingcontext
Private myApplication as Application
Private MyRequest As Request Private MyResponse As Response MYRESPONSE
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 OneendPage ()
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: New VB6 project, ActiveX DLL names P_TEST, class name c_test
The content of the class is as above.
Compilation Generate p_test.dll file
2: Registration
The prompt is running: regsvr32 p_test.dll
Three: Write a PHP file, Test.php4 code is as follows:
$ b = new COM ("p_test.c_test");
$ a = $ b-> Test_number (-454);
Echo $ A;
?>
Run the PHP4 file will display -1
The problem that may be encountered is that the compilation project is not passed,
Microsoft Active Server Pages Object Library
Quote come in, implement "Project-> References" to find the change, and hook
In contrast, PHP4 calls COM should call JavaBean than php4, because after all, is a MS system. You can also write the controls that call the database yourself, call with PHP4, to some extent, and PHP call JavaBean, you can say that "hidden source code" is implemented. Interested friends are welcome.