How PHP Works

I l @ ve RuBoard

PHP is a server-side language, which means that the code you write in PHP resides on a host computer that serves Web pages to Web browsers.

When a visitor goes to a Web site (www.DMCinsights.com, for example), your Internet service provider directs your request to the server that holds the www.DMCinsights.com information.

The server reads the PHP code and processes it according to its scripted directions. In this example, the PHP code tells the server to send the appropriate Web page data to your browser in the form of HTML (Figure i.3). In short, PHP is creating an HTML page on the fly based upon parameters of my choosing, and the server, therefore, contains no static HTML pages.

Figure i.3. This graphic demonstrates how the process works between a Client, the Server, and a PHP module (an application added to the server to increase its functionality) to send HTML back to the browser (albeit in very simplistic terms). All server-side technologies (ASP, for example) use some sort of third-party module on the server to process the data that gets sent back to the client.

graphics/infig03.gif

This differs from an HTML-generated site in that when a request is made, the server merely sends the HTML data to the Web browser and there is no server-side interpretation occurring (Figure i.4). Hence, to the end user 's browser there may or may not be an obvious difference between what home.html and home.php may look like, but how we arrived at that point will be critically altered . The major difference is that by using PHP you can have the server dynamically generate the HTML code. For example, different information could be presented if it is Monday as opposed to Tuesday or if the user has visited the page before or not. Dynamic Web page creation is what sets apart the less appealing, static sites from the more interesting and, therefore, more visited, interactive ones.

Figure i.4. Compare this direct relationship of how a server works with basic HTML to that of Figure i.3. This is also why HTML pages can be viewed in your browser from your own computer since they do not need to be " served ," but dynamically generated pages need to be accessed through a server which handles the processing.

graphics/infig04.gif

The central difference between using PHP and using straight HTML is that every thing PHP does, it does on the server and it then sends the appropriate information to the browser. This book covers how to use PHP to send the right data to the browser.

I l @ ve RuBoard


PHP for the World Wide Web (Visual QuickStart Guide)
PHP for the World Wide Web (Visual QuickStart Guide)
ISBN: 0201727870
EAN: 2147483647
Year: 2001
Pages: 116
Authors: Larry Ullman

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