ServersCOM support on Windows Page 5

COM support on Windows Page 5




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();

?>

Latest Posts

Related Stories