PHP code example of mamazu / partial-functions

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

    

mamazu / partial-functions example snippets


function f(string $greeting = 'Hello', string $name = 'you') {
    return $greeting.', '.$name;
}

echo \Mamazu\PartialFunctions\FunctionInvoker::invoke('f', ['name' => 'Anonymous']);

// Will echo "Hello, Anonymous"

$factory = new \Mamazu\PartialFunctions\PartialFunctionFactory();
$searchInString = $factory->createForCallable('strpos');
$searchInString->apply(['haystack' => 'Hello in PHP']);

$hellopos = $searchInString->call(['needle' => 'hello']);
$phppos = $searchInString->call(['needle' => 'php']);