PHP code example of phpfluent / callback

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

    

phpfluent / callback example snippets


use PHPFluent\Callback\Callback;

$callback = new Callback(
    function () {
        // My callable content.
    }
);

$callback = new Callback(array($object, 'methodName'));

$callback = new Callback('my_function');

$callback = new Callback('str_replace');

$callback->invoke($arg1, $arg2, $arg3);

$callback->invokeArguments($arrayArguments);

$callback($arg1, $arg2, $arg3); // call_user_func() and call_user_func_array() will work like a charm

$callable = new Callback(
    function ($foo, $bar = true) {
        // My callable body
    }
);
$callable->invokeArguments(
    array(
        'foo' => 'PHPFluent',
    )
);

$callable = new Callback(
    function (array $array, TypeTwo $typeTwo, $string, $int, TypeThree $typeThree, $optional = 42) {
        // My callable body
    }
);
$callable(array(), new TypeTwo(), new TypeThree(), 'string', 123);