PHP code example of granam / boolean
1. Go to this page and download the library: Download granam/boolean 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/ */
granam / boolean example snippets
use Granam\Boolean\Boolean;
$booleanFromInteger = new Boolean(12345);
// bool(true)
var_dump($booleanFromInteger->getValue());
$booleanFromString = new Boolean('124578');
// bool(true)
var_dump($booleanFromString->getValue());
$booleanFromFloatString = new Boolean('987.654');
// bool(true)
var_dump($booleanFromFloatString->getValue());
$booleanFromZero = new Boolean(0);
// bool(false)
var_dump($booleanFromZero->getValue());
$booleanFromNull = new Boolean(null, false /* not strict */);
// bool(false)
var_dump($booleanFromNull->getValue());
// ...
// exception is raised (\Granam\Boolean\Tools\Exceptions\WrongParameterType)
new Boolean(null); // implicitly strict - NULL is "unknown" state and therefore forbidden