Exercises, examples and other material relating to training module H115. This topic is presented on public courses
The PHP programmer needs multiple skills. He needs to be a programmer, a graphic artist, a data librarian, a psychologist, a manager, and a technical writer. It's helpful if he knows a little about the subject of the web site he's working on too. This module looks at application planning taking these disciplines into mind, with a view to persuading the trainee to write easy-to-use, robust, pretty, easy-to-upgrade applications within budget and on time.
Articles and tips on this subject | updated |
4691 | Real life PHP application using our course training MVC example Yesterday, I had a requirement to write a multistage web application, using an existing look and feel template, and I did so using the training example from our Learning to Program in PHP. Quick and easy - most of the work is (or was) in working out the text and factors involved - the data - rather ... | 2016-06-05 (longer) |
4641 | Using an MVC structure - even without a formal framework Whether you choose to use a formal framework or not for your web application, understanding the principles of router - model - view - controller and separateting elements of your code into those areas, and considering the whole to be wrapped in a frameowrk with helper functions / methods makes sense. ... | 2016-02-08 |
4326 | Learning to program - comments, documentation and test code Updates material from our courses for newcomers to programming ... we're very happy to help newcomers learn about the basic principles of programming, running an extra day for a very small group on the front of our regular courses for delegates who have programmed before, but in different languages.
In ... | 2014-11-22 |
4118 | We not only teach PHP and Python - we teach good PHP and Python Practice! This week, I'm running a private PHP course in North London, and a private Python course in Bristol ... and it's confirmed and re-confirmed the need for programming standards to be included from the beginning just as much as the mechanisms of the language. I'm not only teaching people how to write ... | 2013-06-22 |
4069 | Even early on, separate out your program from your HTML! Even in the simplest of PHP applications, it's worthwhile to separate the validation of the incoming data from the calculations, and both of those elements from the HTML of the page itself. That means that you can use the calculation stuff - the "business logic" in other applications that use the same ... | 2013-05-04 |
3926 | Filtering PHP form inputs - three ways, but which should you use? There's a vital need to validate user inputs in PHP - to make sure that users have put something sensible into the boxes on your forms. And there are multiple ways of doing this:
a) You can check the incoming strings against regular expressions. In the old days you may have used the ereg functions, ... | 2012-11-24 |
3813 | Injection Attacks - PHP, SQL, HTML, Javascript - and how to neutralise them A delegate for tomorrow's PHP Techniques Course arrived early, and I've spent this afternoon taking a look at the fundamentals of what an "injection attack" is, and how to render attempts to attack your server using such methods harmless.
When you have a web application running, you'll be providing ... | 2012-08-11 |
3820 | PHP sessions - a best practice teaching example Whether you're selling airline tickets, updating financial records, or running a forum, you'll need software on your web server that maintains state. In other words, software which remembers who you are from page to page, remembers what you've been doing, and doesn't insist on you logging in each time.
If ... | 2012-08-11 |
3539 | Separating program and artwork in PHP - easier maintainance, and better for the user I can code reasonably well. But my graphic design sucks. And both skills are needed for even a simple web data entry form, or a small application.
Using the PHP "bull at a gate" approach, both business logic (the code) and look and feel (the graphic art stuff) can be written into a single file, but ... | 2011-12-06 |
1390 | Converting from postal address to latitude / longitude Do you sometimes find odd gaps in new procedures you follow - "I can see everything I need to do to make X happen, except" ?
I hit one of those yesterday. When learning how to interface to Google maps ... all the information was there, except there was no way that I could spot to click on a map and ... | 2011-01-25 |
2430 | Not just a PHP program - a good web application A very busy week so far ... station pickups, a PHP course, hosting an external luncheon meeting and hotel guests at Well House Manor, and providing a venue for, and attending, a meeting of the presidents of some of the local chambers of commerce to discuss towns working together. And it's only just ... | 2010-11-01 |
2679 | How to build a test harness into your PHP I was writing a PHP demonstration yesterday, and I wanted to include a test harness with my class definitions that I could leave in place on the live code on my server, to be silently skipped over ... but which I could re-use at a later date for testing class changes, etc.
How did I do it? An environment ... | 2010-03-16 |
2221 | Adding a newsfeed for your users to a multipage PHP application As I wrote it, I realised this was turning into rather a long article, but never mind. It shows the major new components added to a "4 layer model" application I was working on the weekend before last to add in a newsfeed for logged in users to which they can contribute, together with a headlines-only ... | 2009-06-07 (longer) |
2199 | Improving the structure of your early PHP programs When you first coded in PHP, you probably wrote a different script to handle each form in a series - it's the natural way when you're early in the learning process, but it can lead to repeated code that's hard to follow, and some really horrid complicated conditionals.
On Saturday and Sunday, I demonstrated ... | 2009-05-26 |
936 | Global, Superglobal, Session variables - scope and persistance in PHP "Global" is a poor choice of word! It really means "share this variable in this function with the variable of the same name at the top level" but there isn't a simple, easy better word for that than "Global". If you bring in code within an include / require file, then any top level code's variables ... | 2009-01-01 |
1389 | Controlling and labelling Google maps via PHP "Can you use PHP to control what you show on a Google Map?" An innocent question that lead me off on an interesting exploration when I should (!) have been doing other things - but a very worthwhile couple of hours, and great fun!
How do you do it?
1. Apply for your Google Maps key (you'll need to ... | 2008-09-29 |
1794 | Refactoring - a PHP demo becomes a production page "Refactoring" is a term that I've come across in Extreme Programming, but it's also a relevant topic to consider through the life cycle of any software. Perhaps I had better give a definition ....
Refactoring - the updating / alteration of software or systems, usually done in order to take into account ... | 2008-09-15 (longer) |
1391 | Ordnance Survey Grid Reference to Latitude / Longitude I've already written about conversion of postal addresses to latitude and longitude using Google's interface - but what is I want to convert the Ordinance Survey's grid references into latitude and longitude? Google's interface doesn't support the OS units - and in any case it's "just" a a calculation. ... | 2008-08-30 |
1694 | Defensive coding techniques in PHP? I used to write CAD system software (many moons ago), and when doing so I used what I call "defensive coding techniques". Which meant that I never trusted user input, that a file would be available, that I could write correctly to a device - I tested, tested and tested again. In our environment, it ... | 2008-07-02 |
426 | Robust checking of data entered by users 10 steps to testing the bullet proofing user inputs or how to avoid being caught by nasties when your script goes live!
1. Test it works with intended entries. It's not going to be much good if it falls over when someone entered a valid piece of data!
2. Test it works (fails correctly) with erroneous ... | 2008-05-17 |
123 | Short underground journeys and a PHP book I know London; I was brought up here and I'll travel around by bus and tube (and train) quite happily; usually, I don't even need to bother with a map except, perhaps, a streetmap of the immediate area I'm visiting to find the right street and building.
I'm always amazed by the number of travellers ... | 2008-05-11 |
1623 | PHP Techniques - a workshop So many people know the basis of PHP - the language constructs themselves and how they work individually - but could really benefit from learning how to make the best of those elements. And these techniques for putting the elements together are so important that they should not be crammed onto the end ... | 2008-04-27 |
1533 | Short and sweet and sticky - PHP form input Today I have a short and (very) sweet PHP demo that calls for a user to enter a few pieces of information, and validates them - prior to storage in a database, perhaps.
Why is it "sweet"?
* Because it implements techniques such as sticky fields so that user who make error don't have to keep re-entering
* ... | 2008-02-07 |
1490 | Software to record day to day events and keep an action list Well House Consultants is a diverse company with a small team - operating a hotel and training centre and presenting courses there too - and a such we have a need for efficient communications between us.
"Thank goodness for email" is a cry often heard, with messages being passed back and forth between ... | 2008-01-05 |
1487 | Efficient PHP applications - framework and example There are many elements to your on line application - there's the "look" (1), the "feel" (2), the algorithms behind it (3), and the way the whole thing is bolted together (4).
1. The look may be shared across all the pages of your web site.
2. The feel you choose to use may be shared across all your ... | 2007-12-30 |
1482 | A story about benchmarking PHP I've noticed recently that the response speed of this website hasn't been as brisk as I would have liked, and thought that the cause was a steady growth in the amount of code we run behind the scenes on each page - elements I particularly felt were culprits were identifying visitors to a country by their ... | 2007-12-24 |
1381 | Using a MySQL database to control mod_rewrite via PHP Question: How can I set up Apache httpd / mod_proxy to use a program rather that a list of URL patterns to control my rewrites?
Specify a rewrite map type prg in your httpd.conf or .htaccess file. For example:
RewriteEngine On
RewriteMap tryme prg:/home/trainee/website/andy
RewriteRule (.*\.htm) ${tryme:$1}
Question: ... | 2007-10-05 |
1321 | Resetting session based tests in PHP I was writing and testing a PHP session based application - one in which a series of pages are linked together to make up a complete system - yesterday. And as ever with testing, bugs were found in the code and other things had to be added that meant it needed to be changed.
But it's rather different ... | 2007-08-28 |
1323 | Easy handling of errors in PHP How often have you written a piece of code that's a "spike solution" - it works well on good data - and then spent just as long as you took to do most of the work in fixing errors? I know I have!
These days, I plan my error strategy from minute 0 of hour 0 of day 0. "How to handle errors" is a critical ... | 2007-08-27 |
1194 | Drawing hands on a clock face - PHP Would you like to draw clock face hands on to an image (such as the one shown here, with the time in UK when you called the page up!)? It's easier than you think using PHP's GD module.
Instead of supplying a fixed image in your <img> tag, provide the URL of a PHP script that reads an image and ... | 2007-05-19 |
1047 | Maintainable code - some positive advice Don't ask what class an object belongs to
Don't enquire where your cursor is
Don't do two things in a call
Don't duplicate data or code
Don't put two or more values in the same cell
There's lots of different ways of coding - from "dog's dinner" to "Picasso". The dog's dinner looks a mess and is very ... | 2007-05-18 |
1182 | Painting a masterpiece in PHP In PHP, you can write a program that looks like a Rembrandt, or one that makes the dog's dinner look tidy. It's not only the mechanism of the language you need to learn to do a good job, but how to apply it.
This week, on my public PHP course, I have a group which is very IT professional in background, ... | 2007-05-11 |
1181 | Good Programming practise - where to initialise variables It's a good idea to initialise your variables directly before you use them for the first time if you're going to use them as accumulators.
By accumulator I mean that you're going to write assignments such as:
$n += 4; # Perl
incr notepad; # Tcl
lappend flcodes [lindex ... | 2007-05-11 |
1166 | Back button - ensuring order are not submitted twice (PHP) Ensuring that forms aren't "double submitted" is critically important on certain automated data entry applications - the classic example being an absolute need NOT to allow your user to place an order twice if he / she uses the "back" button and presses submit again.
I came across an article on a Java ... | 2007-04-30 |
1052 | Learning to write secure, maintainable PHP We're running a PHP course this week, and as ever I went around the room on the first day checking with the delegates what their "hot points" were, noting them on a board to the side to ensure that all the points ARE covered.
Security and maintainabily came up. And came up strong. Duly noted on the ... | 2007-01-30 |
945 | Code quality counts We're celebrating Geekmas this weekend ... and we've got a full place. Plus others who are coming in for the day. Really good session yesterday on the good DESIGN of an interactive (scripted) web site that "mines" user information to give a tailored presentation, and a great intro by Paddy to Python's ... | 2006-11-26 |
896 | PHP - good coding practise and sticky radio buttons With PHP, it's very easy to knock together a page with a couple of radio buttons and a small application just be taking the "bull at a gate" approach - but if you develop code like this, and without planning, you end up with a very long application that's hard to follow and maintain and - unless you've ... | 2006-10-19 |
839 | Reporting on the 10 largest files or 10 top scores What are the biggest 10 files in or below this directory?
What are the 20 'worst' spams I have received in the last month?
What are the five top scores recorded for a popular game on my web site?
It's a very common requirement indeed to provide a program to answer questions like these, and if you've ... | 2006-08-19 |
563 | Merging pictures using PHP and GD
I wanted, regrettably, to fade (tear) one picture into another - a train at Melksham into a picture of a disused railway trackbed. We have one of those nearby at Seend, where the Trowbridge - Devizes - Reading - London train service used to run. Here's another 2 options I looked at:
and
The ... | 2006-06-09 |
237 | Crossfertilisation, PHP to Python Rasmus Lerdorf's "Do you PHP" talk on our Geek Cruise last October was brilliant - I heard so much about what's behind PHP and how its originator intends it to be used that it give me a real strong understanding of best practise - you'll find further details availble here and elsewhere on this site.
Python ... | 2006-06-05 |
Thinking through your design.
Tools to help you design.
Designing a smaller application example.
A note on using PHP in a Web environment.
Writing maintainable code.
Code documentation.
Use of functions and include files.
Version issues.
Coding Standards.
And all the languages in one file?.
Writing code for different databases.
Miscellany.
Error handling and software testing.
Bad characters.
Expect the unexpected and check everything.
Error numbering and handling.
Data validation, sessions, XML/XSLT, SQL.
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.