For 2023 (and 2024 ...) - we are now fully retired from IT training. We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.
Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!
I am also active in many other area and still look after a lot of web sites - you can find an index ((here)) |
PHP module H103
Variables, Operators and Expressions
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, PHP Programming, Learning to program in PHP
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 | 4642 | A small teaching program - demonstration of principles only Putting a program on a public facing web server is like putting a car on the driveway outside your home, then going away on holiday. You had better make sure the car is locked, and that if it's an open-decked truck there's nothing left on the deck. Or you had better make sure that the driveway is secured. ... | 2016-02-08 | 4324 | Learning to program - variables and constants Further material from our "learning to program in ...." courses ... an introduction to variables and constants
variable basics
Information - data - needs to be stored in a program between statements. Or rather it needs to be stored in the computer's memory. At the lowest of levels, that's a binary ... | 2014-11-22 | 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 |
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 somewhat 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 [here].
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
Ruby,
Lua,
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.
|