Hudzilla.org - the homepage of Paul Hudson
Contents > Java and COM > Getting started with COM Wish List | Report Bug | About Me ]

14.1.1     Instantiating an object

This is NOT the latest copy of this book; click here for the latest version.

PHP handles COM objects as native PHP objects, meaning that you can read and write variables, and also call functions, just like you would on any other object. The COM object class is simple "COM", and you need to pass it the name of COM component to create as the parameter to its constructor.

To find out the names of the COM components you have installed (you almost certainly have hundreds), click Start, then Run, then enter "regedit" and click OK. From the three on the left, open up HKEY_CLASSES_ROOT, and you will see a long list of file extensions, probably ending around ".zip". After that, you will see a big long list of the names of COM components - just pick one from there, and you are all set.



Note that COM scripts should generally be run from the command line. Running them through a web server is possible, but COM objects that interact with the user on the server need to have special permissions granted to them. This can usually be accomplished using the Services administrative tool, but this may be different on your version of Windows.

Just below is a screenshot of how to enable Apache to launch visible desktop applications that can be interacted with:



It is important to note that starting a complicated COM object for the first time will be quite slow, but a lot of the information is cached by Windows for several minutes after the object is freed, so subsequent start ups will be much faster. If you find a script is executing slowly, try it out a few times to see whether it is just the initial start up time that is slow.





<< 14.1 Getting started with COM   14.1.2 Basic COM >>
Table of Contents
Want to see this stuff in print? PHP in a Nutshell takes the core topics covered here, adds in thousands of edits from the editorial team and myself, and combines them to make an unbeatable reference for PHP programmers at all levels.



My latest book has hundreds more tips on how to use PHP, Apache, and MySQL, plus Perl, Python, shell scripts, performance tuning, and more!



Top-right shadow
 
Bottom-left shadow Bottom shadow

Comments from other readers
Be the first to add a comment to this chapter!



Add comment
Please note that by posting a comment here you are committing it to the public domain. This is important so that others can make use of your code themselves, and also so that I can incorporate helpful notes directly into the main text. Comments are limited to 2000 characters in length.

If you are reporting an error in the content, please tell me directly.

Your name/email address:
Your comment:
 
Now, in order to verify that you're a real person, please answer this simple question: what is seven plus four?
The answer is:
(please write in
numbers, eg 19)


Top-right shadow
 
Bottom-left shadow Bottom shadow