Skip to content

Instantly share code, notes, and snippets.

@kobus1998
Last active April 9, 2020 12:20
Show Gist options
  • Save kobus1998/dfedb6db069e868d0939db563fc96d90 to your computer and use it in GitHub Desktop.
Save kobus1998/dfedb6db069e868d0939db563fc96d90 to your computer and use it in GitHub Desktop.
execute any function by this
<?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