note 22179 added to function.phpversion

From: Date: Sun, 09 Jun 2002 17:09:53 +0000
Subject: note 22179 added to function.phpversion
Groups: php.notes 
Request: Send a blank email to php-notes+get-31629@lists.php.net to get a copy of this message
The above example is incorrect. It does not take the significance of each number into account, and compares them as independent numbers. It also has the incorrect inequality operator for the action it is trying to achieve. I suggest using this instead: # return True if given php version is the same as or older than the version currently running function check_php_version ($version) { $testSplit = explode ('.', $version); $currentSplit = explode ('.', phpversion ()); if ($testSplit[0] < $currentSplit[0]) return True; if ($testSplit[0] == $currentSplit[0]) { if ($testSplit[1] < $currentSplit[1]) return True; if ($testSplit[1] == $currentSplit[1]) { if ($testSplit[2] <= $currentSplit[2]) return True; } } return False; } -- http://www.php.net/manual/en/function.phpversion.php http://master.php.net/manage/user-notes.php?action=edit+22179 http://master.php.net/manage/user-notes.php?action=delete+22179 http://master.php.net/manage/user-notes.php?action=reject+22179

« previous php.notes (#31629) next »