Changes

An Overview of PHP

375 bytes added, 17:11, 23 May 2007
How Does PHP Work?
Given that a web browser knows nothing about PHP in a web page, then clearly something has to be done with any PHP script in the page before it reaches the browser. This is where the PHP pre-processing module comes in. The PHP module is, as mentioned previously, integrated into the web server. The module tells the web server that when a page is to be served which contains PHP script (identified by special markers) that it is pass that script to the PHP pre-processing module and wait for the PHP module to send it some content to replace that script fragment. The PHP processing module understands PHP, executes the PHP script written by the web developer and, based on the script instructions, creates output that the browser will understand. The web server substitutes the content provided by the PHP pre-processor module in place of the PHP script in the web page and sends it to the browser where it is rendered for the user to view.
 
To help understand this concept let's take a quick look at a before and after scenario. The following HTML contains some PHP script that is designed to output an HTML header tag:
 
<pre>
 
<html>
<head>
<title>A PHP Example</title>
</head>
<body>
 
<?php
echo '<h1>This line of HTML was generated by a PHP script embedded into an HTML document
?>
 
</body>
</html>
 
</pre>