Last active
April 9, 2020 12:20
-
-
Save kobus1998/dfedb6db069e868d0939db563fc96d90 to your computer and use it in GitHub Desktop.
execute any function by this
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 | |
class ManyFunctions | |
{ | |
/** | |
* @param string $sMethod | |
* @param array $aParams | |
* @return mixed|void | |
*/ | |
public function __call($sMethod, $aParams = []) | |
{ | |
if (function_exists($sMethod)) { | |
return $sMethod(...$aParams); | |
} | |
} | |
public function doHelloWorld($hello, $place) | |
{ | |
return "{$this->ucfirst($hello)} {$this->trim($place)}!"; | |
} | |
} | |
$oMf = new ManyFunctions(); | |
echo $oMf->doHelloWorld('hello', ' world '); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment