X

Check PHP version

From WordPress 3.2, PHP 5.2.4 is required for it to run. While developing plugins for this version you might need to check that the PHP version is up to date.

PHP has a built in function for checking versions, namely version_compare(). With this function, you can compare different version numbers, and PHP_VERSION is a constant you can use to get the current PHP version, which is just what we need for this check.

Code Snippet:

<?php
if ( version_compare(PHP_VERSION, '5.2.4', '<') ) {
    wp_die('PHP 5.2.4 is required.');
};
?>

Comments  Leave a Reply

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!