PHP code example of darkfriend / php5-type

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

    

darkfriend / php5-type example snippets


use \darkfriend\helpers\TypeHelper;

var_dump(
    TypeHelper::toStrict('false'), // bool(false)
    TypeHelper::toStrict(null), // NULL
    TypeHelper::toStrict(0), // int(0)
    TypeHelper::toStrict('0'), // int(0)
    TypeHelper::toStrict('1'), // int(1)
    TypeHelper::toStrict(1), // int(1)
    TypeHelper::toStrict('1.1'), // float(1.1)
    TypeHelper::toStrict(1.1), // float(1.1)
    TypeHelper::toStrict(true), // bool(true)
    TypeHelper::toStrict(false), // bool(false)
    TypeHelper::toStrict('my string'), // string(9) "my string"
    TypeHelper::toStrict('') // string(0) ""
);
TypeHelper::toStrictType($value)