Created
November 11, 2019 12:39
-
-
Save kobus1998/159ee4ccd4f8fc88f26c67c7a3932cd0 to your computer and use it in GitHub Desktop.
function in parameter with already set parameters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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