SHARE
Facebook X Pinterest WhatsApp

COM support on Windows Page 5

Jul 20, 2010
ServerWatch content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More



On Windows platforms, PHP4
now offers support for COM components. This means that practically
all Windows applications can be manipulated from PHP4. The COM model
at the heart of Microsoft’s architecture is such that any
Windows application can provide a certain number of components and
exposed methods, which are entry points for manipulating
applications from other applications.

A few lines of code tend to be more useful than a long
description, so let’s examine the following example. The code below
does nothing less than boot Word, create a new document from it, add
text to this document, and then save everything on the disk before
quitting.

<?php
$word = new COM(“word.application”)
or
 die(“Impossible to instantiate
WordApp”);
print “Word is running, version
{$word->Version}n”;

$word->Visible=1;

$word->Documents->Add();
$word->Selection->TypeText(“This
is a test…”);
$word->Documents[1]->SaveAs(“test_com_php.doc”);
$word->Quit();

?>

Recommended for you...

What Is a Container? Understanding Containerization
What Is a Print Server? | How It Works and What It Does
Nisar Ahmad
Dec 8, 2023
What Is a Network Policy Server (NPS)? | Essential Guide
Virtual Servers vs. Physical Servers: Comparison and Use Cases
Ray Fernandez
Nov 14, 2023
ServerWatch Logo

ServerWatch is a top resource on servers. Explore the latest news, reviews and guides for server administrators now.

Property of TechnologyAdvice. © 2025 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.