1.2.1661. version_compare Operator¶
version_compare()’s third argument is checked for value. The third argument specifies the operator, which may be only one of the following : <, lt, <=, le, >, gt, >=, ge, ==, =, eq, !=, <>, ne. The operator is case sensitive.
Until PHP 8.1, it was silently reverted to the default value. It is a deprecated warning in PHP 8.1 and will be finalized in PHP 9.0. It is recommended to fix this parameter in any PHP version.
<?php
// return true
var_dump(version_compare('2.0', '2.1', '<'));
// returns false
var_dump(version_compare('2.0', '2.1', '>'));
// returns NULL and might be interpreted as false
var_dump(version_compare('2.0', '2.1', 'as'));
?>