O'Reilly logo

WordPress 3 Plugin Development Essentials by Everett Griffiths, Brian Bondari

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Testing PHP version

The following is how you test your what version of PHP looks like:

/**
* @param string the minimum version of PHP required to run, e.g. '5.2.14'
*/
public static function php_version_gt($ver)
{
$exit_msg = __("MyPlugin requires PHP $ver or newer.
Talk to your system administrator about upgrading");
if ( version_compare( phpversion(), $ver, '<') )
{
self::$errors[] = $exit_msg;
}
}

Again, you would add a corresponding function call to your loader.php file:

// Run Tests.
MyPlugin_tests::wp_version_gt('3.0.1');
MyPlugin_tests::php_version_gt('5.2.14');

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required