From eef467984d8992df1437a08e481dd87e2ba842fc Mon Sep 17 00:00:00 2001 From: Gabor Hojtsy Date: Sun, 11 Nov 2001 12:29:50 +0000 Subject: [PATCH] Adding that nice version_compare function, with examples git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@61976 c90b9560-bf6c-de11-be94-00142212c4b1 --- functions/info.xml | 67 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 65 insertions(+), 2 deletions(-) diff --git a/functions/info.xml b/functions/info.xml index 3c2fce4338..cebe2e6d9f 100644 --- a/functions/info.xml +++ b/functions/info.xml @@ -1,5 +1,5 @@ - + PHP options & information PHP options/info @@ -1483,7 +1483,8 @@ echo "Current PHP version: ".phpversion(); - See also phpinfo, + See also version_compare, + phpinfo, phpcredits, php_logo_guid, zend_version. @@ -1723,6 +1724,68 @@ putenv ("UNIQID=$uniqid"); + + + version_compare + Compares two "PHP-standardized" version number strings + + + Description + + + int version_compare + string version1 + string version2 + string + + operator + + + + + + version_compare compares + two "PHP-standardized" version number strings. This + is useful if you would like to write programs working + only on some versions of PHP. + + + version_compare returns -1 if + the first version is lower than the second, 0 if they + are equal, and +1 if the second is lower. + + + If you specify the third optional + operator argument, you + can test for a particular relationship. The possible + operators are: <, + lt, <=, + le, >, + gt, >=, + ge, ==, + =, eq, + !=, <>, + ne respectively. Using + this argument, the function will return 1 if + the realtionship is the one specified by the + operator, 0 otherwise. + + + + <function>version_compare</function> example + +// prints -1 +echo version_compare("4.0.4", "4.0.6"); + +// the all print 1 +echo version_compare("4.0.4", "4.0.6", "<"); +echo version_compare("4.0.6", "4.0.6", "eq"); + + + + + + zend_logo_guid