Exercises, examples and other material relating to training module H103. This topic is presented on public courses
Learning to program in PHP,
PHP Programming,
Beginning PHP - weekend course / hobby / club / leisure users
Writing a straightforward but meaningful executable web page in PHP. You'll learn how to read data from the user via a form, how to perform calculations using operators, and store the results in computer memory using variables. You'll also learn how to include those results in your response page.
| Articles and tips on this subject | updated |
| 3917 | BODMAS - the order a computer evaluates arithmetic expressions What order does a computer program use to evaluate expressions? If I write
2 + 3 * 4 + 5
does it start off, left to right ...
2 + 3 is 5
5 * 4 is 20
20 + 5 is 25
No! it does not, even though the newcomer might think that was the most natural way for ... | 2012-11-10 |
| 3916 | PHP variables - dynamically typed. What does that mean? When we're programming, we store data in our computer memory in one step of our process, then read it back for further reference or processing in a later step. In the very early days, this was planned out using the numeric location in the computer memory, but very rapidly programming languages ... | 2012-11-10 |
| 3278 | Do I need to initialise variables - programming in C, C++, Perl, PHP, Python, Ruby or Java. Starting with a clean slate. Are variables initisialised, and if so, how? Even with this fundamental question, languages vary considerably.
C and C++
From my (e)mailbag ...
"""In a piece of code we’ve written we declare an array, but we do not fill the elements with values, we assume (dangerous ... | 2011-05-05 |
| 2215 | If nothing, make it nothing. Here's a peculiar PHP statement I wrote this morning:
if ($aindex[$chk] == "") $aindex[$chk] = "";
What was I doing? I am actually checking to see whether there's anything in an array element and if there isn't (which could be because it's empty or because it doesn't yet exist), then it ... | 2009-06-03 |
| 748 | Getting rid of variables after you have finished with them If you've finished with a variable in your program, you can usually just leave it "in situe" and it will be destroyed and the memory it occupied will be released when you exit from your program. In many languages, variables within named blocks of code have an even shorter "shelf life" - by default, a ... | 2006-06-09 |
| 483 | Double Dollars in PHP What does this print?
<?php
$first = "fur";
$last = "feather";
$$first = "yum yum ";
${"$first$last"} = "yikes";
print "$fur $furfeather";
?>
It prints "yum yum yikes".
In PHP, you can write a variable name within a variable name, and that's what I've done in this example.
The variable called ... | 2006-06-05 |
2253
Examples from our training material
| header.txt | File to be included in master example ?> |
| k1.php | A calculation in PHP |
| k2.php | A calculation with variables |
| k3.php | Getting a variable from a form - OLD style |
| k3a.php | Getting a form variable - new and more secure style |
| k4.php | Example of comment types |
| master.php | PHP page that calls in an include file ?> |
| result | Master and Header code merged |
| simsan.php | Simple sanitisation and sticky field example |
Pictures
We ran a PHP course for Pepperdine University
Background information
Some modules are
available for download as a sample of our material or under an
Open Training Notes License for free download from
http://www.training-notes.co.uk.
Topics covered in this module
Expressions and operators.
Variables.
Getting a value from a form.
Alternative ways of getting values from a form.
Comments in PHP.
Including a file.
Complete learning
If you are looking for a complete course and not just a information on a single subject, visit our
Listing and schedule page.
Well House Consultants specialise in training courses in
Python,
Perl,
PHP, and
MySQL. We run
Private Courses throughout the UK (and beyond for longer courses), and
Public Courses at our training centre in Melksham, Wiltshire, England.
It's surprisingly cost effective to come on our public courses -
even if
you live in a different
country or continent to us.
We have a technical library of over 700 books on the subjects on which we teach.
These books are available for reference at our training centre. Also
available is the Opentalk
Forum for discussion of technical questions.