Home >Backend Development >PHP Tutorial >Using COMWindows in PHP4--Introduction_PHP Tutorial
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.