Publishers of technology books, eBooks, and videos for creative people

Home > Articles > Web Design & Development > PHP/MySQL/Scripting

  • Print
  • + Share This
From the author of How PHP Works

How PHP Works

When you go to a Web site (I’ll use as my example here), your Internet Service Provider directs your request to the server that holds the information. Because this site was designed in PHP, the server reads the PHP 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. This data is in the form of HTML that the browser can display as it would a standard HTML page. In short, PHP creates an HTML page on the fly based on parameters of my choosing; the server contains no static HTML pages.

Figure 2 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.

With a purely HTML-generated site, the server merely sends the HTML data to the Web browser; there is no server-side interpretation.

Figure 3 Compare this direct relationship of how a server works with basic HTML to that of Figure 2. 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.

To the end user and their browser, there may not be an obvious difference between what and look like, but how the pages arrived at that point are critically different. The major difference: By using PHP, you can have the server dynamically generate the HTML code. In this example, the index.php page referenced above displays news items that it retrieves chronologically from a database.

Dynamic Web page creation is what sets apart the less appealing, static sites from the more interesting, and therefore more visited, interactive ones.

  • + Share This
  • 🔖 Save To Your Account