Skip to content

Instantly share code, notes, and snippets.

@kobus1998
Created November 11, 2019 12:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kobus1998/159ee4ccd4f8fc88f26c67c7a3932cd0 to your computer and use it in GitHub Desktop.
Save kobus1998/159ee4ccd4f8fc88f26c67c7a3932cd0 to your computer and use it in GitHub Desktop.
function in parameter with already set parameters
<?php
$i = 1;
function plus1(int $i) {
return $i + 1;
}
$f = function () use ($i) {
echo plus1($i);
};
// can be used to execute the next responsibility in chain-of-responsibilities
function execute($f) {
$f();
}
execute($f); // 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment