Coding ConventionsOr stuff I d …

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.

Leave a Reply

%d bloggers like this:

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close