05.05.2013 Views

Programming PHP

Programming PHP

Programming PHP

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

External Commands<br />

<strong>PHP</strong> uses the default command shell of Windows for process manipulation. Only<br />

rudimentary Unix shell redirections and pipes are available under Windows (e.g.,<br />

separate redirection of standard output and standard error is not possible), and the<br />

quoting rules are entirely different. The Windows shell does not glob (i.e., replace<br />

wildcarded arguments with the list of files that match the wildcards). Whereas on<br />

Unix you can say system("someprog php*.inc"), on Windows you must build the list<br />

of filenames yourself using opendir( ) and readdir( ).<br />

Common Platform-Specific Extensions<br />

There are currently over 80 extensions for <strong>PHP</strong>, covering a wide range of services and<br />

functionality. Only about half of these are available for both Windows and Unix<br />

platforms. Only a handful of extensions, such as the COM, .NET, and IIS extensions,<br />

are specific to Windows. If an extension you use in your scripts is not currently<br />

available under Windows, you need to either port that extension or convert<br />

your scripts to use an extension that is available under Windows.<br />

If you use <strong>PHP</strong> as a web server plug-in (SAPI), the extensions must be thread-safe.<br />

Some extensions depend on third-party libraries that may not be thread-safe, rendering<br />

them incompatible with the SAPI plug-in.<br />

Unfortunately, the level of thread safety in <strong>PHP</strong> extensions is poorly documented,<br />

and it will require testing on your part to discover where you may run into difficulty.<br />

Fortunately, the more popular an extension is, the greater chance there is of that<br />

extension being available on Windows.<br />

In some cases, some functions are not available under Windows even though the<br />

module as a whole is. checkdnsrr( ), in the Networking module, is just one example<br />

of this problem.<br />

Windows <strong>PHP</strong> does not support signal handling, forking, or multithreaded scripts. A<br />

Unix <strong>PHP</strong> script that uses these features cannot be ported to Windows. Instead, you<br />

should rewrite the script to not take advantage of those features.<br />

Interfacing with COM<br />

COM allows you to control other Windows applications. You can send file data to<br />

Excel, have it draw a graph, and export the graph as a GIF image. You could also use<br />

Word to format the information you receive from a form and then print an invoice as<br />

a record. After a brief introduction to COM terminology, this section shows you how<br />

to interact with both Word and Excel.<br />

This is the Title of the Book, eMatter Edition<br />

Copyright © 2002 O’Reilly & Associates, Inc. All rights reserved.<br />

Interfacing with COM | 359

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!