Coding Conventions
Or stuff I do when programming.
This is PHP orientated but applies elsewhere too.
I like to code using classes, and the functions in those classes for the most part return true
or false
. If a function returns false, then an internal variable, $this->error gets the error message set by the function.
When I’m working on forms, my validation function returns true
or false
, but $this->error is an array indexed by form elements which allows me to define a per-element error message that my printForm() function can use.
On the same subject, I populate a single array with form elements which makes it easier to walk through those elements.