You've already seen how PHP can be used to interface with Java components and JavaBeans. But here's something you didn't know - PHP can (shock shock! horror horror!) even be used to interface with Microsoft COM objects on the Windows platform. Will this be a happy marriage? Read on to find out.
Since COM is a Microsoft invention, it won't surprise you to hear that PHP's COM extension is only available for the Windows version of PHP. If you're using *NIX - well, you're outta luck. Shut down your browser and read a book instead.
If you're still interested, though, pop open your favourite editor and create a PHP script containing the following lines of code (this example assumes that you have a properly-installed copy of Microsoft Excel on your system):
// create an object instance
$excel = new COM("Excel.Application") or die("Excel could not be
// pop open the Excel application
$excel->Visible = 1;
// turn off alerts
$excel->DisplayAlerts = 0;
// add a workbook
// close the application
$excel = null;
Now, when you run this script through your Web browser, the
following things should happen very fast:
1. Microsoft Excel will start up automatically.
2. A new workbook will be added.
3. The workbook will be automatically saved as "C:\Inventory.xls"
4. Microsoft Excel will automatically shut itself down.