Learning PHP sans bad habits
I've received some fatalistic responses to my last installment related to what I see as problems with PHP teachings. In particular, I fear we teach people to write applications in ways that are reckless to the fact that these individuals likely read no more than 1-2 PHP books and move on to start writing their application.
Now I'll present some solutions I propose to the challenges of teaching PHP without encouraging bad habits from the beginning.
Chapter 1: Intro to PHP syntax using the commnd-line
Chapter 2: Make your first dynamic web page using our small framework (hello world)
The framework handles: data escaping input and output, proper sql injection protection, and data/presentation separation. The student needn't understand all of this yet, but will be explained.
Chapter 3: Variables & Arrays
Chapter 4: Conditionals, Loops & Functions
Chapter 5: Classes
Chapter 6: Sending/Receiving data on the web.
Chapter 7: How to create additional pages in the framework
Chapter 8: Creating forms
Chapter 9: Dissect the framework input/output, presentation and database aspects
Chapter 10: Show how failing to do these things is insecure
Chapter 11: Create additional views/flow using OO framework
Chapter 12: Create a simple application with 3-4 views
This describes the mostly the PHP aspects of a book. This book could easily use SQLite and save the MySQL for another book where it can be properly introduced. It could also include some MySQL education to increase its marketability. The framework itself sounds like a big undertaking, but in fact it can be kept extremely simple as governed by the examples put forth herein. In addition, the frameworks simplicity will allow it to be dissected later in the book for the education of the reader. Finally, when someone finishes the book (or the worst risk with current books if they don't finish it, they'll still have the right ideas and not go willy-nilly writing an application using $_GET and $_POST without thinking twice.
[tags]teaching, learning, php[/tags]