Compare versions in WordPress

/**
 * Use PHP's version_compare() to check the version
 * of WordPress (or a plugin or theme for that matter).
 * 
 * Get currently installed version of WP either using 
 * get_bloginfo( 'version' ) OR use the global $wp_version. 
 * Either is OK.
 */

global $wp_version;

// alternate method
// $wp_version = get_bloginfo( 'version' )

if ( version_compare( $wp_version, '5.0', '>=' ) ) {
    
    echo "WordPress is at or above 5.0";
    
} else {
    
    echo "WordPress version is below 5.0";
    
}