Last active
January 31, 2018 22:35
-
-
Save nhalstead/1f23acaebf86d73493de55d005483535 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
/** | |
* Function Switch | |
* Call the Funciton acording to the True or False Value. | |
* If any more Paramiters are passed after the first 3 | |
* they are passed as paramiters for the called funciton. | |
* | |
* @param boolean The Selection of the Funciton to execute. | |
* @param Callable If the Boolean is True. | |
* @param Callable If the Boolean is False. | |
*/ | |
function _q($switch, callable $if_true, callable $if_false){ | |
$input = func_get_args(); | |
unset($input[0], $input[1], $input[2]); | |
if($switch == true) { | |
return call_user_func_array($if_true, $input); | |
} | |
else if($switch == false) { | |
return call_user_func_array($if_false, $input); | |
} | |
} | |
// _q(true, function(){}, function(){}); | |
_q(false, | |
function($e = 1){ | |
// The True Statment | |
echo $e+10; | |
}, | |
function($e = 0){ | |
// The False Statment | |
echo $e-10; | |
}, | |
1111 | |
); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment