Static versus reference versus global

Hi guys I was fiddling a bit with an error reporting array (storing). Ideally I want to have several functions that pass along what goes wrong to an accessible array (so outside the scope of the function). For instance "creditcard number is invalid" (or whatever).

The code below shows 4 (simplistic) methods to accomplish this. Apart from the first one they all have something I like.

Well, how far OOP do you want to go? I would have an object representing the form itself (doesn't have to be so specific as to be for that individual form) which acts like a data repository. You can get the form data from it, even as simply as wrapping functionality around $_POST, and push validation/error messages into it.

In general if you're considering anything remotely OOP then global variables and static/global functions are the wrong direction.

Well, how far OOP do you want to go? I would have an object representing the form itself (doesn't have to be so specific as to be for that individual form) which acts like a data repository. You can get the form data from it, even as simply as wrapping functionality around $_POST, and push validation/error messages into it.

In general if you're considering anything remotely OOP then global variables and static/global functions are the wrong direction.

Ha Requinix, As always thanks for your reply! I guess your right. This isn't really object orientated and I am more or less abusing it with static functions. I should indeed create some form class. (lazy as always )
The pass by reference I like, but it's a bit of a pain in the * to add all those parameters. Hopefully I can soon show off my Form class. (edit: trying to build it now