How do I invoke a COM component I write in PHP? _php Tutorials

Source: Internet
Author: User
First write the ActiveX Dll:
Create a new VB6 project, the ActiveX DLL will name the project P_test, the class name is C_test, the file contents of the class are 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 = 0
End Function

Compile build P_test.dll file

Registered

Prompt to run: regsvr32 p_test.dll

To write PHP files, the TEST.PHP4 code is as follows:

$b =new COM ("P_test.c_test");
$a = $b->test_number (-454);
echo $a;
?>

The problem that may be encountered is that when compiling the project, it is necessary to refer to the Microsoft Active Server Pages Object Library in order to implement "project->references" to find the library and check it.

http://www.bkjia.com/PHPjc/631932.html www.bkjia.com true http://www.bkjia.com/PHPjc/631932.html techarticle first write the ActiveX DLL: Create a new VB6 project, the ActiveX DLL named Project P_test, the class name is C_test, the class file content is as follows: Option Explicit Private Myscriptingcontext As SCR ...

  • 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.