Changes

Jump to: navigation, search

An Overview of PHP

9 bytes added, 17:33, 7 June 2007
no edit summary
When a user visits a web site or clicks on a link on a page the browser sends a request to the web server hosting the site asking for a copy of the web page. The web servber receives the request, finds the corresponding web page file on the file system and sends it back, over the internet, to the user's browser.
Typically the web server doesn't pay any attention to the content of the file it has just transmitted to the web browser. As far as the web server is concerned the web browser understands the content of the web page file and knows how to interpret and render it so that it appears as the web designer intended.
Now let's consider what kind of web page content a web browser understands. These days a web page is likely to consist of HTML, XHTML and JavaScript. The web browser contains code that tells it what to do with these types of content. For example, it understands the structure HTML in terms of rendering the page, and it has a JavaScript interpreter built in that know knows how to execute the instruction instructions in a JavaScript script. A web browser, however, knows absolutely nothing about any PHP script that may be embeeded in an HTML document. If a browser was serverd a web page containing PHP it would not know how to interpret that code.
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 to 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 paragraph tag:
In summary, PHP has many advantages, and those listed here are just some of the reasons for the success of PHP. Many people will offer their own reasons for using PHP - and this fact alone is testament to the power and flexibility of PHP.
Now that we know a little about [[The History of PHP]] and have an overview of how it works we can start looking at how to develop PHP based web sites, begining beginning with [[Creating a Simple PHP Script]].

Navigation menu