Main Content

Extra PHP Examples

Archive - Originally posted on "The Horse's Mouth" - 2009-03-09 13:28:02 - Graham Ellis

Yesterday evening and this morning, I was helping with some specific PHP questions ... resulting in some new examples that I've put on the web site.

• A program which can be used / allows logins only between 3pm and 5pm on a Wednesday afternoon (and could easily be adapted to let people in at breakfast time on Fridays instead)
Demo and source

• A simple session demonstration, which allows and controls logins ... if you log in with user name "terry" and password "trotter" you can try it out.
Demo and source code for main page and source code for form generator

• And finally, and example of how you should (and Should NOT) echo large chunks of HTML from your PHP program ... I feel really sad when I see a book with loads of echo statements all down one side of the example, when a "here document" or an exit from PHP mode would be so much cleaner. The illustration is photographed from one of the books in our library, and shows the way constant text output should NOT be done. It makes my toes curl!
Run the code and see the source

Aside from these examples, I've added two more articles that relate to the session - the first is about how to set up a MySQL database through PHP and the second covers those vital ancillaries such as Usability, maintainability, and keeping the user in mind.

There is a lot - an awful lot - more to PHP that just this sprinkling of issues - these are just the ones that have come up in the last 24 hours, and for one particular person. If you're new to PHP, have a look at our PHP course; if you've got some PHP background but want to go further making real use of the power of the language, consider our PHP techniques workshop instead.