Skip to content

Instantly share code, notes, and snippets.

@kennethrapp
Created October 8, 2013 22:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kennethrapp/328b6bd1bda8a8f94092 to your computer and use it in GitHub Desktop.
Save kennethrapp/328b6bd1bda8a8f94092 to your computer and use it in GitHub Desktop.
hey look... fun with __call()!
<?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