-
-
Save kennethrapp/328b6bd1bda8a8f94092 to your computer and use it in GitHub Desktop.
hey look... fun with __call()!
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 sum{ | |
private $key = 'array_sum_of'; | |
function __call($name, $args){ | |
return (stripos($name, $this->key) == 0)? array_sum(explode("_", substr($name, strlen($this->key)))): 0; | |
} | |
} | |
$array_sum = new sum(); | |
echo $array_sum->array_sum_of_1_2_9000_3_2_1_4(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment