PHP code example of donurks / php-typed-array

1. Go to this page and download the library: Download donurks/php-typed-array 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/ */

    

donurks / php-typed-array example snippets



chdir(dirname(__DIR__));
rks\AbstractTypedArray
{
    protected $type = \stdClass::class;
}

$myOwnType = new MyOwnType([
    new \stdClass(),
    new \stdClass(),
    new \stdClass(),
]);


chdir(dirname(__DIR__));
Array\TypeString([
    'string1',
    'string2',
    'string3'
]);

$booleans = new \Donurks\TypedArray\TypeBoolean([
    true,
    false,
    true
]);

$integers = new \Donurks\TypedArray\TypeInteger([
    1,
    124,
    3434
]);

$floats = new \Donurks\TypedArray\TypeFloat([
    1.234,
    1.2e3,
    7E-10
]);


chdir(dirname(__DIR__));
Array\TypeString([
    'string1',
    'string2',
    'string3'
]);

$booleans = new \Donurks\TypedArray\TypeBoolean([]);
$booleans[] = true;

try {
    $booleans[] = 'not-a-boolean';    
} catch (\Donurks\TypedArray\Exception $e) {
    die($e->getMessage());
}
sh
composer