| |||||||||||
| |||||||||||
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 very good at repeatedly debugging the same code - it's going to be unreliable too.
Much better to move all the standard stuff into functions and just keep the data in the main program or even in data files. To give you an idea, here's a sample I've just written with sticky radio buttons - as a demonstration - showing you how I've separated the mechanism from the actual data: <?phpA real life application would have some "business logic" to actually handle the data entered, of course, and I would move the functions out into a separate include file so that they could be used across all my work. Similarly, the HTML template would be separated out for easier maintainance by an HTML expert. Ah - we're headed for the "4 layer model" again ... Run the code here (written 2006-10-17 03:41:53) Associated topics are indexed under H115 - Designing PHP-Based Solutions: Best PracticeH110 - PHP - HTML Web Page Data Handling
Some other Articles
Python - function v methodPython - extend v append on a list Courses at Well House Manor Too much for the National Trust PHP - good coding practise and sticky radio buttons Welcome, Martin Where quality costs less Visibility A pattern in change Well House Manor Hotel, Melksham, Wiltshire 1638 posts, page by page
Link to page ... 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33 at 50 posts per pageThis is a page archived from The Horse's Mouth at http://www.wellho.net/horse/ - the diary and writings of Graham Ellis. Every attempt was made to provide current information at the time the page was written, but things do move forward in our business - new software releases, price changes, new techniques. Please check back via our main site for current courses, prices, versions, etc - any mention of a price in "The Horse's Mouth" cannot be taken as an offer to supply at that price. Link to Ezine home page (for reading). Link to Blogging home page (to add comments). |
| ||||||||||
PH: 01144 1225 708225 • FAX: 01144 1225 707126 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho | |||||||||||