(no version information, might be only in CVS)

COM -- COM class


$obj = new COM("server.object")


The COM class provides a framework to integrate (D)COM components into your PHP scripts.


string COM::COM ( string module_name [, string server_name [, int codepage]])

COM class constructor. Parameters:


name or class-id of the requested component.


name of the DCOM server from which the component should be fetched. If NULL, localhost is assumed. To allow DCOM com.allow_dcom has to be set to TRUE in php.ini.


specifies the codepage that is used to convert php-strings to unicode-strings and vice versa. Possible values are CP_ACP, CP_MACCP, CP_OEMCP, CP_SYMBOL, CP_THREAD_ACP, CP_UTF7 and CP_UTF8.

Example 1. COM example (1)

// starting word
$word = new COM("word.application") or die("Unable to instanciate Word");
"Loaded Word, version {$word->Version}\n";

//bring it to front
$word->Visible = 1;

//open an empty document

//do some weird stuff
$word->Selection->TypeText("This is a test...");
$word->Documents[1]->SaveAs("Useless test.doc");

//closing word

//free the object
$word = null;

Example 2. COM example (2)


= new COM("ADODB.Connection") or die("Cannot start ADO");
$conn->Open("Provider=SQLOLEDB; Data Source=localhost;
Initial Catalog=database; User ID=user; Password=password"

$rs = $conn->Execute("SELECT * FROM sometable");    // Recordset

$num_columns = $rs->Fields->Count();
$num_columns . "\n";

for (
$i=0; $i < $num_columns; $i++) {
$fld[$i] = $rs->Fields($i);

$rowcount = 0;
while (!
$rs->EOF) {
    for (
$i=0; $i < $num_columns; $i++) {
$fld[$i]->value . "\t";
$rowcount++;            // increments rowcount



$rs = null;
$conn = null;


Sites of interest: Web Hosting : Reseller Hosting : Website Hosting : HTML Editor : Web Design Templates : Free Web Hosting : ASP code examples : PHP & MySQL Code Examples
  Copyright 2004 Evrsoft Developer Network. Privacy policy - Link to Us

Contact Evrsoft