If the installed version is 8.1, and the function is called with the string 7.4, it should return true because 8.1 is more recent than 7.4. however it returns false, because the first conditional check fails, so we fall through to the second conditional (the elseif).
The problem with this second conditional is that it only examines the minor version, not taking into account the major version. So in our example, it compares 1 to 4. Since 1 is less than 4, this condition succeeds, and the function returns false.
This fix also simplifies the function by using a native PHP method that is purpose built for this use case
If the installed version is 8.1, and the function is called with the string 7.4, it should return true because 8.1 is more recent than 7.4. however it returns false, because the first conditional check fails, so we fall through to the second conditional (the elseif).
The problem with this second conditional is that it only examines the minor version, not taking into account the major version. So in our example, it compares 1 to 4. Since 1 is less than 4, this condition succeeds, and the function returns false.
This fix also simplifies the function by using a native PHP method that is purpose built for this use case