note 58145 modified in function.phpversion by bjori

From: Date: Tue, 07 Mar 2006 13:43:26 +0000
Subject: note 58145 modified in function.phpversion by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-104987@lists.php.net to get a copy of this message
The version 4.3.10-16 does not "respect" the requiement for the above code. Use this fuction. sample call: if(!check_version(PHP_VERSION, "4.1.0") ) { echo 'Current PHP version: ' . PHP_VERSION . ' is too low for this code!<p>'; } Function: # Compares versions of software # versions must must use the format ' x.y.z... ' # where (x, y, z) are numbers in [0-9] function check_version($currentversion, $requiredversion) { list($majorC, $minorC, $editC) = split('[/.-]', $currentversion); list($majorR, $minorR, $editR) = split('[/.-]', $requiredversion); if ($majorC > $majorR) return true; if ($majorC < $majorR) return false; // same major - check ninor if ($minorC > $minorR) return true; if ($minorC < $minorR) return false; // and same minor if ($editC >= $editR) return true; return false; } --was-- The version 4.3.10-16 does not "respect" the requiement for the above code. Use this fuction. sample call: if(!check_version(PHP_VERSION, "4.1.0") ) { echo 'Current PHP version: ' . PHP_VERSION . ' is too low for this code!<p>'; } Function: # Compares versions of software # versions must must use the format ' x.y.z... ' # where (x, y, z) are numbers in [0-9] function check_version($currentversion, $requiredversion) { list($majorC, $minorC, $editC) = split('[/.-]', $currentversion); list($majorR, $minorR, $editR) = split('[/.-]', $requiredversion); if ($majorC > $majorR) return true; if ($majorC < $majorR) return false; // same major - check ninor if ($minorC > $minorR) return true; if ($minorC < $minorR) return false; // and same minor if ($editC >= $editR) return true; return true; } http://php.net/manual/en/function.phpversion.php

« previous php.notes (#104987) next »