Home >Backend Development >PHP Tutorial >Using COMWindows in PHP4--Introduction_PHP Tutorial

Using COMWindows in PHP4--Introduction_PHP Tutorial

WBOY
WBOYOriginal
2016-07-13 17:24:55961browse

Introduction
PHP4’s built-in COM functions are really attractive to people who program in win32 environment. There isn't much documentation on this at the moment. This article will use 3 examples (MS office 2000, Excel, Adobe Distiller) to explain how to use COM programming in PHP4. Microsoft has been developing COM technology under different names for many years. In this article OLE, OLE Automation, ActiveX and COM are all the same thing: using a piece of encapsulated code to implement some functions for a Windows application. PHP4's COM establishes a connection with the object (instantiates the object) and then uses its methods and properties.
If you want to redevelop these examples, here is my configuration:
Windows 98 - MS Office 2000
Apache 1.3.9 Windows
PHP4.02 Dev (08-20-00) Running as CGI

COM tags in PHP4
Let’s start with the COM functions in PHP4. To instantiate a control, you need a "new" operator and the object's "OLE identifier":

COM is a class name reserved by PHP4, which passes $identifier to the constructor. We now have an instantiated control, and its methods and properties can be easily referenced using OOP technology. For example:
[Object]->[method1]->[method2]->..->[property]; ?>
It’s that simple!
If it cannot be quoted like this (sometimes PHP syntax errors will be caused when the name or value of an attribute contains special characters such as dots or brackets), PHP4 COM also provides two functions:
bool com_set(class com_object, string property name, string property_value);
mixed com_get(class com_object, string property_name);
?>
Finally, PHP4 also supports DCOM, which can create an object on a remote computer Example.


$Instance = new COM(string "Component name", string "remote_server_address");
?>
The above are all the functions, there are no other functions to remember Got it!
Note: PHP may support the use of DCOM on Unix in the future.

Identifiers, methods and properties
Identifiers are strings similar to the following:
MS Word: "Word.Application" or "Word.Application.9"
MS Excel: " Excel.Application" or "Excel.Sheet"
ADOBE Acrobat: "Exch.application" or "PdfDistiller.PdfDistiller"
As the last identifier indicates, not all object names are obvious . If you don't have documentation for VBA, you can look in the HKEY_CLASSES_ROOT folder of the registry: below the extension list you can see the name of the application, and the CLSID subfolder has the available COM identifiers.
Applications should provide documentation about COM's methods and properties. For example, in Office 2000, open the program, use the shortcut key to open the VB editor and then use to open the object editor. Enter the name of a method or attribute, select a member and select Help to get a description of the member. You can also visit MSDN. An Excel example is: http://msdn.microsoft.com/library/officedev/off2000/xltocobjectmodelapplication.htm


Translated from: http://www.phpbuilder.com/columns/alain20001003 .php3

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/532113.htmlTechArticleIntroduction The built-in COM functions of PHP4 are really attractive to people who program in win32 environment. There isn't much documentation on this at the moment. This article will use 3 examples (MS office 2000, Exc...
Statement:
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