Changes

Jump to: navigation, search

An Overview of PHP

683 bytes added, 17:16, 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 paragraph tag:
<pre>
<?php
echo '<p>This line of HTML was generated by a PHP script embedded into an HTML document</p>';?> </body></html> </pre> The above example looks very miuch like standard HTML until the part surrounded by ''<?php'' and ''?>''. These are markers that designate where the PHP scriptlet begins and ends. When the web server finds this it sends it to the PHP module. the PHP module interprets it, converts it to HTML and sends it back to the web server. the web server then send sthe following to the browser: <pre> <html><head><title>A PHP Example</title></head><body> <p>This line of HTML was generated by a PHP script embedded into an HTML document</p> </body></html> </pre> <h1>This line of HTML was generated by a PHP script embedded into an HTML document</h1>';
?>

Navigation menu