PHP code example of mpd / util-strint-cmp

1. Go to this page and download the library: Download mpd/util-strint-cmp library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mpd / util-strint-cmp example snippets


use mpd\Util\StrIntCmp\StrIntCmp;

$a = '-350317994473186284556312754796813594860152465582658277960247';
$b = '-63245865813051830934382781315128857497460797902242257911260';

//use the best backend available. in order(gmp > bcmath > StrIntCmp::strIntCmp)
echo(StrIntCmp::cmp($a, $b)); // -1
//force use own implementation
echo(StrIntCmp::strIntCmp($a, $b)); // -1

echo(StrIntCmp::cmp("5", "2")); //  1
echo(StrIntCmp::cmp("2", "5")); // -1
echo(StrIntCmp::cmp("7", "7")); //  0

echo(StrIntCmp::isValidInt("75a")); // false
echo(StrIntCmp::isValidInt("14"));  // true

class StrIntCmp {
    /* Properties */
    const SIZE; 
    public static $handler;
    /* Methods */
    public static cmp($a, $b): int
    public static strIntCmp($a, $b): int
    public static isValidInt($a): bool
    public static init(): void
}