ParagonIE_Sodium_Compat::compare() public WP 1.0
Compare two strings, in constant-time. Compared to memcmp(), compare() is more useful for sorting.
{} It's a method of the class: ParagonIE_Sodium_Compat{}
No Hooks.
Return
Int
. If < 0 if the left operand is less than the right If = 0 if both strings are equal If > 0 if the right operand is less than the left
Usage
$result = ParagonIE_Sodium_Compat::compare( $left, $right );
- $left(string) (required)
- The left operand; must be a string
- $right(string) (required)
- The right operand; must be a string
Code of ParagonIE_Sodium_Compat::compare() ParagonIE Sodium Compat::compare WP 5.7
public static function compare($left, $right)
{
/* Type checks: */
ParagonIE_Sodium_Core_Util::declareScalarType($left, 'string', 1);
ParagonIE_Sodium_Core_Util::declareScalarType($right, 'string', 2);
if (self::useNewSodiumAPI()) {
return (int) sodium_compare($left, $right);
}
if (self::use_fallback('compare')) {
return (int) call_user_func('\\Sodium\\compare', $left, $right);
}
return ParagonIE_Sodium_Core_Util::compare($left, $right);
}