PHP code example of vatson / isolated-callback

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

    

vatson / isolated-callback example snippets



Vatson\Callback\IsolatedCallback;

$cb = function() {
    return array_slice(range(1, 100000), rand(1,100), rand(1,10));
};

$icb = new IsolatedCallback($cb);
$random_slice = $icb();


Vatson\Callback\IsolatedCallback;

$slice_length = rand(1,5);
$cb = function($max_range) use($slice_length) {
    return array_slice(range(1, $max_range), rand(1,$max_range), $slice_length);
};

$icb = new IsolatedCallback($cb);
$random_slice = $icb(1000);



use Vatson\Callback\IsolatedCallback;

$cb = function() {
    $popo_object = new \stdClass();
    $popo_object->property = 'value';
    return $popo_object;
};

$icb = new IsolatedCallback($cb);
$property = $icb()->property;