PHP_MAJOR_VERSION
? Screw it, I’ll do it myself.
1 2 3 4 5 6 7 |
|
Just to be clear, there’s nothing necessarily criminal about today’s code. Rather, it’s an example of code that could be written in a cleaner, more efficient manner. Today’s lesson might be, “Knowing your language is the path to better code.”
Now you know about PHP_MAJOR_VERSION
, and knowing is half the battle.
Today’s snippet comes courtesy of an anonymous submitter.
UPDATE: Yeah, remember what I said about “Knowing your language …”? Well, I just got schooled. Commenter Josh Woody demonstrates how using PHP_MAJOR_VERSION
wouldn’t really be any better, and his point is well taken. Since PHP_MAJOR_VERSION
has only been available since PHP 5.2.7, it wouldn’t be much use in any version prior to 5.2.7. /facepalm.