Greetings,
This is more of a code convention question than a coding question, and I'm just curious to get other peoples opinions on this and why they feel the way they do.
We have a situation at work where we were writing a class to use as a "transition" to PHP 5, and have need to define a number of error condition constants.
Being from a C/C++ background, it seems more natural to define them using the define() function. A co-worker coming from a java background thinks they should be defined as class variables, with an agreed upon convention that they are constants (this will be implied by our naming conventions, so as to not "accidentally" change one) and when PHP 5 comes out they will be converted to 'static final'. Neither of us feel either one is a great solution, and we're concerned that whichever way we do it will be wrong. 🙂
Looking through a lot of PHP code it seems most people go the define() route (PEAR::Error, PEAR:: DB, etc) so I wonder if they do it more for historical reasons, or if there are actual performance benefits to be gained or if there is something else we're not considering.
In addition to your answer for the above question, would PHP5's inclusion of 'static final' make a difference to your answer?
Thanks,
Chris