Working …
This value you provided is not a number. Please try again.
This value you provided is not an integer. Please try again.
The value entered is not a valid Vanderbilt Medical Record Number (i.e. 4- to 9-digit number, excluding leading zeros). Please try again.
The value you provided must be within the suggested range
The value you provided is outside the suggested range
This value is admissible, but you may wish to double check it.
The value entered must be a time value in the following format HH:MM within the range 00:00-23:59 (e.g., 04:32 or 23:19).
This field must be a 5 or 9 digit U.S. ZIP Code (like 94043). Please re-enter it now.
This field must be a 10 digit U.S. phone number (like 415 555 1212). Please re-enter it now.
This field must be a valid email address (like joe@user.com). Please re-enter it now.
The value you provided could not be validated because it does not follow the expected format. Please try again.
Required format:
REDCap Logo
Plugins, Hooks, & External Modules
Developer methods for
Plugins, Hooks, & External Modules
Hook functions

REDCap Developer Tools:
Documentation for Plugins, Hooks, & External Modules

REDCap Version 14.9.1
REDCap::versionCompare
(REDCap >= 5.5.0)
REDCap::versionCompare — Compares two "REDCap-standardized" version number strings
Description
mixed REDCap::versionCompare ( string $version1 , string $version2 [, string $operator ] )
Compares two "REDCap-standardized" version number strings. You may use the constant REDCAP_VERSION (i.e. the current REDCap version) for either parameter version1 or version2. This method is useful if you would like to write plugins that behave differently on different versions of REDCap.
Parameters
version1
First version number
version2
Second version number
operator
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. This parameter is case-sensitive, so values should be lowercase.
Return Values
By default, returns -1 if the first version is lower than the second, 0 if they are equal, and 1 if the second is lower. When using the optional operator argument, the function will return TRUE if the relationship is the one specified by the operator, FALSE otherwise.
Examples
Example #1:
The examples below use the REDCAP_VERSION constant, which contains the value of the REDCap version that is executing the code.
if (REDCap::versionCompare(REDCAP_VERSION, '6.0.0') >= 0) {
    echo 'I am at least REDCap version 6.0.0, my version: ' . REDCAP_VERSION . ".\n";
}
if (REDCap::versionCompare(REDCAP_VERSION, '5.3.0') >= 0) {
    echo 'I am at least REDCap version 5.3.0, my version: ' . REDCAP_VERSION . ".\n";
}
if (REDCap::versionCompare(REDCAP_VERSION, '5.0.0', '>=')) {
    echo 'I am using REDCap 5, my version: ' . REDCAP_VERSION . ".\n";
}
if (REDCap::versionCompare(REDCAP_VERSION, '5.0.0', '<')) {
    echo 'I am using REDCap 4 or an even earlier version, my version: ' . REDCAP_VERSION . ".\n";
}
REDCap 14.9.1 - © 2024 Vanderbilt University