1.4. Requesting Data from a Web PageHow all of these pieces integrate together can be tricky to understand. If a web server detects PHP code, it determines whether the file is a PHP file, and if so, turn over the processing of the page to the PHP interpreter without any additional participation by the web browser. But if you include an external CSS file, your browser issues a separate request for that file before viewing the page. 1.4.1. PHP Interpretation on the ServerThis processing of the PHP on the server is called server-side processing. When you request a web page, you trigger a whole chain of events. Figure 1-2 illustrates this interaction between your computer and the web server (host of the web site). Figure 1-2. While the user only types in a URL and hits Enter, there are several steps that occur behind the scenes to handle that requestHere's the breakdown of Figure 1-2:
The HTML file called directory.html (requested in Figure 1-2) is called a static web page. It is static because everyone who requests the directory.html page gets exactly the same page. For the web server to customize the returned page, PHP and MySQL are added to the mix. Figure 1-3 illustrates the extra steps that occur in the chain of events on the web host. Figure 1-3. The PHP interpreter, MySQL, and the web server cooperate to return the pageEach step in the chain is listed here:
This may seem like a lot of steps, but all of this processing happens automatically every time a web page with PHP code is requested. When developing dynamic web pages, you work with a variety of variables and server components, which are all important to having an attractive, easy to navigate, and maintainable web site. Next, it's time to install the three major cogs needed to make this work: Apache, PHP, and MySQL. |