PHP4 invoke the COM component that you wrote

Source: Internet
Author: User
Finished PHP4 call JavaBean, and want to try to call COM, began to think it difficult, oneself with VB6 wrote an active DLL in PHP4 call, immediately successful, than the call JavaBean more convenient, the following about my steps.

One: Write an ActiveX Dll with VB6

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: New VB6 project, ActiveX DLL named Project P_test, class named C_test

The file contents of the class are as above.

Compiling the build P_test.dll file

II: Registration

Prompt to run: regsvr32 p_test.dll

Three: Write PHP file, TEST.PHP4 code 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 that may be encountered is that when compiling a project, you will not pass the

Microsoft Active Server Pages Object Library

The reference comes in, concretely realizes "project->references" to find the change storehouse, and hooks on

In contrast, PHP4 call COM should be better than PHP4 call JavaBean, because after all, the MS System. You can also go to write their own call to the database control, with the PHP4 call, to some extent, and PHP call JavaBean, it can be said that the implementation of the "hidden source code."



Contact Us

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: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.