PHP code example of dwo / comparator

1. Go to this page and download the library: Download dwo/comparator 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/ */

    

dwo / comparator example snippets


$operator = '==';
$argument1 = 1;
$argument2 = 1;
if(Comparator::compare($operator, $argument1, $argument2)) {
    //do something
}


//Example 'bool' operator
if(Comparator::compare('bool', true, $_GET['activated'])) {
    //do something
}

//Example 'date' operator
if(Comparator::compare('day', 'now', $date)) {
    //do something
}

//Example 'date_range' operator
if(Comparator::compare('date_range', new \DateTime(), $dateFrom, $dateTo)) {
    //do something
}