IPT home IPT A Virtual Approach by Peter Whitehouse
Quick Links:
Information and Intelligent Systems Social and Ethical Implications Human Computer Interaction Software and Systems Engineering eXercise Files Course Outline and Assessment A-Z of Geeky Acronyms Terrace Work Program 2004 Sillybus FAQ = Frequently Asked Questions Help

PHP Programming

Introduction to Scripting

Home | Variables & Operators | Input & Output | Decisions & Loops| Sub-Programming | Built-ins


PHP is a server-side scripting language. Code for PHP web applications are stored on a web server in specially named files (.php typically). When users request the files via their browser (using that specific URL) the server PARSES the file looking for code to execute and executes it if it can. After execution, any resultant output (in the form of HTML) is sent to the client browser window as the web page the client requested.


This differs specifically from compiled languages like Lazarus(visual Pascal), C++ and so on in that the commands you write are not executed on your machine (the client "running" them) but rather on a capable server that must then communicate back to you the results of those commands. Compiled languages typically have their programs (executables and supporting data files) in a machine-ready form (often already translated into machine language like .exe files) ready to run on your local processor.

The model for programming web applications using PHP is different to other development, PHP is not a great language for capturing interactivity and is typically coupled with Javascript, Java and HTML in order to regain some of the "interactivity" typical of modern applications. This means that published PHP applications are typically a mixture of client side coding (javascript runs in the client browser) and server side scripting (PHP engine).

PHP is also often coupled with MySQL to make database-driven interactive "live" websites - you can learn more about this elsewhere in this resource

In this section you will learn some of the features of the PHP language, conventions and plenty to get you started. The web is full of great definitive references and tutorials for PHP. Consider this section as a starting point for your PHP investigations.

Some examples live to web

Code Structure

Files containing PHP commands MUST be named with the .php file extension to indicate to the SERVER that there is code to execute. The files themselves often contain HTML and PHP code intermingled and this gets confusing until you get your head around the notion of TAGS as ways of MARKING UP sections to do particular things.

A "typical" web page might have the following basic structure:

   page contents go here

In the above example, the page contains pairs of tags as containers (eg. <head> ... </head>). Many HTML tags contain a beginning (<tag>) and end (</tag>) but not all. In general, VISIBLE web content occurs in the BODY of the web page.

We will develop "templates" that contain most of the code needed for a basic page so you do not have to worry too much about this, suffice to say the tags must be encoded correctly else the page will fail.

To place some PHP code in the BODY of the page, you create a "PHP container" thus:

<h1>Hello World</h1>

   echo '<br>'.'Gidday Fred';


In the above example, there is a Heading followed by the message "Gidday Fred". Notice the PHP container that has a start (<?php) and an end (?>) Everything between is considered CODE and will be executed by the SERVER before you see it. In the other sections we will learn more about what sorts of things you can get PHP to do.

A PHP web page can contain a mixture of HTML and PHP, and multiple PHP containers - so long as the begin-end tags for PHP containers do not overlap lots of variation is possible.

Related resources:




©Copyright t 1992..2018+. Edition 26.150117
Creative Commons License
This work is licensed under a
Creative Commons Attribution-NonCommercial-ShareAlike 2.1 Australia License