Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
 
20.9.2014 - We have just updated our course layouts and descriptions and added our 2015 schedule.

'Proper' PhP

Posted by Gee (Gee), 24 October 2007
Hi Graham

I've just got back to the office after being in your latest TCL course (I was the one asking all the PhP questions). The course contents and tuition was great and I might speak to the powers that be about a PhP one as the benefits would be huge for all parties.

I've been looking at the sc5.php example: "Best Practice blah blah", is this an industry standard way of doing things or the best way you have found of doing things? Do you ever find it slows browsing pages down? Could you remind me of the feature in Apache that renames the files/links?

Thanks

Gordon


Posted by admin (Graham Ellis), 25 October 2007
Taking those in turn.

Firstly, start from the sc6 file rather than sc5 - source code here.  It uses the modern $_SESSION superglobal array rather than the older alternatives .  $_SESSION was introduced long enough ago for systems that don't support it to be getting pretty rare, and it's the way forward for the future.

The example is mine, but it's based on a technique taught by Rasmus Lerdorf who's the originator of PHP and remains the father figure, with application along the lines he suggested.  There are a few areas where I criticise my code  from time to time and discuss whether I shouild have done "x" or "y" while writing it - indeed I have a diary note to change a few things around and move it from excellent practise to truely best.

Typically, the pages don't load slowly - with processor speed as high as it is, you're typically constratined by line lag / bandwidth still - but, yes, it can heva an effect. Indeed I have a wrapper around our own site at the moment and the lag is verging on the unacceptable - you may have noticed.  Also our ISP appears to have allowed the server to be rather heavily loaded and that needs attendtion - but it's nothing to do with the PHP script / technique.  

If timing does prove to be a major problem on a multipage application, you can use includes within individual switched sections to bring in only the code that's needed to validate the previous page (not all vallidation code) and only the code that's needed to prepare for the next page (not prepare for all pages)

And at the other end - where you have one URL for lots of pages - you're looking for mod_rewrite. See here

Posted by Gee (Gee), 25 October 2007
I guess this method allows for the development of "skins" for forums and such like. It's all very interesting and something I will consider in the furture, although initially it looks complex. Separating the men from the boys I suspect.

Thanks

Gordon

Posted by admin (Graham Ellis), 26 October 2007
For multi-step applications it works very well indeed.  I can tell you of an urgent requirement for a booking system that took all of one day for me to bolt together based on sc6 as a template.   BUT it needs a bit of "working into" the first time.  

On our public PHP courses, I have my delegates grab a copy of the various files off the server, install it in their own area, and get it to work in a modified form.  It doesn't take very long at all, and everyone leaves with a starting point for using the technique ... even if they end up changing all of the web helpers, main logic and templates.



This page is a thread posted to the opentalk forum at www.opentalk.org.uk and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

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