Created
February 23, 2011 08:56
-
-
Save Zegnat/840189 to your computer and use it in GitHub Desktop.
The lol class will let you code your applications with the word lol only! (Or any other word.)
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 lol { | |
private $functions; | |
function __construct() { | |
$functions = get_defined_functions(); | |
$this->functions = $functions['internal']; | |
} | |
public function __call($name, $arguments) { | |
$l = $i = strlen($name); | |
$repeater = ''; | |
$times = 0; | |
while ($i--) { | |
$repeater .= $name[$l-$i-1]; | |
if (preg_match('#^('.preg_quote($repeater).')+$#i',$name)) { | |
$times = $times<($a=strlen($name)/strlen($repeater))?$a:$times; | |
} | |
} | |
$times--; | |
$name = $this->functions[$times]; | |
unset($this->functions[$times]); | |
array_unshift($this->functions,$name); | |
return call_user_func_array($name,$arguments); | |
} | |
} | |
$lol = new lol; | |
print $lol->lollollollollol('teststring').'<br>'; // strlen('teststring') == 10 | |
print $lol->lol('teststring').'<br>'; // strlen('teststring') == 10 | |
$theRing = new lol; | |
print $theRing->MordorMordorMordorMordorMordor('teststring').'<br>'; // strlen('teststring') == 10 | |
print $theRing->Mordor('teststring').'<br>'; // strlen('teststring') == 10 | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment