[wp-hackers] looking for opinions on php5-only plugins
if.website at gmail.com
Wed Oct 7 21:56:01 UTC 2009
On Wed, Oct 7, 2009 at 12:49 PM, Otto <otto at ottodestruct.com> wrote:
> Version number checking is a bad idea. It's simply not accurate enough
> and doesn't tell you what you need to know.
> Checking for extensions, or functions provided by extensions (using
> function_exists or class_exists, etc) is much more accurate and sure
> to work. That's what I check for in the activation checks, whenever a
> plugin depends on something that somebody might not have.
I agree with the principle of checking behavior rather than version
especially (rather than depending on user-agent strings, for example).
However, to me what makes PHP 5 much better than PHP 4 is not
especially that PHP 5 has a few more functions like
timezone_offset_get(), but the syntactical differences: true private
methods, abstract classes, object interfaces, error handling, etc.
The trouble is that PHP 5-specific syntax won't even parse in PHP 4,
so I'm at a loss as how to alert PHP 4 users gracefully that my
WordPress plugin requires PHP 5. I suppose I could check for the
existence of arbitrary PHP 5-only functions, but that runs the risk of
false positives thanks to something like wp-includes/compat.php or the
plugin equivalent. And it, like version number checking, violates the
principle of checking for behavior.
So does anybody have any suggestions about a robust way to warn PHP 4
users that a WordPress plugin uses PHP 5 syntax?
More information about the wp-hackers