PHP Website Programming

What does PHP stand for and what does it do?

PHP is a recursive definition, much like GNU (GNU Not Unix), and is an acronym for “PHP: Hypertext Preprocessor”. This is engineering humour and mirrors the recursive nature of some of the standard programming constructs that any programmer will be familiar with. It follows closely the syntax of the C programming language and is not dissimilar to Javascript syntax (though still very different in both usage and design). PHP is a ‘server-side scripting language‘ - what this means is that you write a script (a small program-like piece of code) which is parsed (read and acted upon) by the PHP interpretor (a program installed on your server which knows how to read your script and analyse it). The results of the interaction between the interpretor and your script usually result in some form of output, either data directed into a database or some text converted into HTML for display purposes.
If that all sounds a little confusing, then think of it like this: PHP is a program used to serve up the content you tell it and pass this to the users’ browsers. So, PHP runs and executes your script (which you have stored on a page) before that page is sent across the Internet to the end user’s browser (e.g. Firefox or Internet Explorer). The script runs on the server; this is the place (it is actually a dedicated computer) where your web site is hosted, i.e. saved and stored for people to read from. Compare this to Javascript, which is a language which does not run on the server but instead runs on the user’s computer (which is called a client). Scripts written in Javascript are referred to as ‘client-side scripts’.
Why would you want something like PHP on your site. Well HTML is static and does not change. You cannot create a web page displaying the date and time using HTML alone, you need to get this ‘real-time’ data from the server hosting your site - and this is where a server-side scripting language comes in. There are many such languages, but PHP remains the most common and is a very neat and flexible way to add content (usually text, but images and other things also) to your pages. Going back to the example, if you wish to display today’s date on your page, you can write a PHP script and within it call the ‘Date()’ function. This will command the PHP interpretor to request the current date from the server and to display it on your page. This is a very simple example of PHP usage. However, used in conjunction with MySQL (a language to save data in databases), then PHP becomes very powerful indeed. See PHP and MySQL for more information on these languages.

Leave a Reply

You must be logged in to post a comment.