How PHP Scripts Work


Before you learn how to write PHP scripts, it is important to realize exactly how development using PHP works. To understand this, you must first understand the interaction between a client (for instance, your Web browser) and the Web server. When a client requests a document from the Web server, normally the Web server retrieves the document (if it exists, of course) and sends it to the client. In most cases, this document is an HTML file, image, and so on, that the client then processes and displays in your browser window. In contrast, instead of sending the document directly to the client, an intermediate step called preprocessing is taken for PHP scripts. During this step, the PHP interpreter processes the PHP script requested, executes any code within the script, and sends the output back to the Web server to be sent to the client. Even though the primary purpose of the PHP script in general is to generate HTML content, during a script's execution everything from accessing databases to sending emails may take place.

One inherent difference between this programming language and other development platforms is that all code is executed on the server. This means that no special programs, plug-ins, or libraries are necessary for clients to execute the scripts. As long as the client can properly request documents from a Web server, it can take advantage of the PHP scripting language on that server.

NOTE

Although this is the most common way of using PHP, PHP can also be used client-side to develop applications in both Windows and Unix environments. See Chapter 17, "Using PHP for Console Scripting," for further details.




PHP 5 Unleashed
PHP 5 Unleashed
ISBN: 067232511X
EAN: 2147483647
Year: 2004
Pages: 257

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net