Home Accessibility Courses Twitter The Mouth Facebook Resources Site Map About Us Contact
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))

Well House Consultants
You are on the site of Well House Consultants who provide Open Source Training Courses and business hotel accommodation. You are welcome to browse and use our resources subject to our copyright statement and to add in links from your pages to ours.
Other subject areas - resources
Java Resources
Well House Manor Resources
Perl Resources
Python Resources
PHP Resources
Object Orientation and General topics
MySQL Resources
Linux / LAMP / Tomcat Resources
Well House Consultants Resources
Extras Resources
C and C++ Resources
Ruby Resources
Tcl/Tk Resources
Web and Intranet Resources
PHP module H115
Designing PHP-Based Solutions: Best Practice
Exercises, examples and other material relating to training module H115. This topic is presented on public courses Deploying LAMP - Linux, Apache, MySQL, Perl/PHP, Linux Web Server, Learning to program in PHP, PHP Programming, Extra Day, Intermediate PHP - weekend course / hobby / club / leisure users, PHP Programming, Learning to program in PHP

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.

Related technical and longer articles
What makes a good variable name?
Error messages in PHP
Portrait of the Author of PHP
Keeping the PHP and the HTML apart
The practical solution of requirements using PHP

Articles and tips on this subjectupdated
4691Real 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 ...
4641Using 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. ...
4326Learning 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 ...
4118We 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 ...
4069Even 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 ...
3926Filtering 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, ...
3813Injection 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 ...
3820PHP 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 ...
3539Separating 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 ...
1390Converting 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 ...
2430Not 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 ...
2679How 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 ...
2221Adding 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 ...
2199Improving 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 ...
936Global, 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 ...
1389Controlling 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 ...
1794Refactoring - 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 ...
1391Ordnance 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. ...
1694Defensive 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 ...
426Robust 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 ...
123Short 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 ...
1623PHP 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 ...
1533Short 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 * ...
1490Software 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 ...
1487Efficient 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 ...
1482A 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 ...
1381Using 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: ...
1321Resetting 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 ...
1323Easy 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 ...
1194Drawing 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 ...
1047Maintainable 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 ...
1182Painting 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, ...
1181Good 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 ...
1166Back 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 ...
1052Learning 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 ...
945Code 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 ...
896PHP - 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 ...
839Reporting 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 ...
563Merging 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 ...
237Crossfertilisation, 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 ...
Examples from our training material
4lm_business.inc   business logic for 4 layer demo
4lm_template.htp   HTML template for 4 layer model
4lm_top.php   Full PHP application / 4 layer model - start here
4lm_webhelpers.inc   Web Helpers for 4 layer model demo
demo.htp   Template for sc5.php4 and sc6 "best practise" examples
details.xsl   Style sheet to format one particular piece of information from an XML file
grgen.php   Generate a graphic to show a text string
gruse.php   Capthca Driver
hph.php   Using an array to set a generalised form
hph2.php   Sticky form, Regex Validation, save to db when AOK
images.xml   XML data used by demonstration program
imnames.xsl   Style sheet used to get a list of all images held in XML file
mvc2.php   MVC Framework and Helpers - with exceptions and validation
mvc_fhc.php   MVC Framework and Helpers / Components all in one!
niceform.php   Form, validation, sticky fields, email results
sc5.php   Main demo script - uses sessions, functions, SQL, XML and XSLT
sc6.php   Main demo script; uses sessions, functions, SQL, XML and XSLT
slidetell.php   Look up records (paginated) in a MySQL table.
sqldemo.inc   SQL functions for sc5 and sc6 demos
stdsess.inc   standard functions for sc5 and sc6 demos
xsltdemo.inc   xslt functions for sc5 and sc5 demos
Web Application design - best practise
Steps in a PHP based web application
Designing your web / CGI / Perl application
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
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.
Error handling and software testing.
Bad characters.
Expect the unexpected and check everything.
Error numbering and handling.
Data validation, sessions, XML/XSLT, SQL.
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.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2024: 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.net/resources/H115.html • PAGE BUILT: Sun Oct 11 14:50:09 2020 • BUILD SYSTEM: JelliaJamb