PHP code example of dealnews / constraints

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

    

dealnews / constraints example snippets


// A very simple example
$constraint = \DealNews\Constraints\Constraint::init();
$value = "1";
try {
    $value = $constraint->check($value, ["type" => "integer"]);
    // $value will now be integer 1
} catch (\DealNews\Constraints\ConstraintException $e) {
    echo $e->getMessage();
}