I’m creating a pre-installation checklist for a program. The program requires PHP5, so I need the checklist-script to check for PHP5’s availability.
There is a function as phpversion(), that will return in the format of 5.3.6 or similar. However, I want the checklist to be very straight forward and simply tell you yes or no. So displaying the current version isn’t helping me that much. Okay, one way is to use the phpversion() and remove the comas etc. But isn’t there a neater way? (Weirdly enough, there is no information on this anywhere)
So, How to simply check if servers PHP version is 5 or above?
if (...) {
echo 'Server has PHP5 or above!';
} else {
echo 'Servers PHP version is lower then PHP5';
}
There is a predefined constant:
http://nl.php.net/manual/en/reserved.constants.php#reserved.constants.core
So:
Above only works for PHP > 5.2.7, try this instead for lower versions:
It is suggested in one of the comments here: http://www.php.net/manual/en/function.phpversion.php#91816