Created
April 27, 2012 20:31
-
-
Save hugdubois/2512762 to your computer and use it in GitHub Desktop.
lol
This file contains hidden or 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 | |
/** | |
* | |
* LOL | |
* | |
* Output : | |
* | |
* bar0 : bar | |
* bar1 : bar | |
* bar2 : bar | |
* bar3 : bar | |
* bar4 : bar | |
* bar5 : bar | |
* bar6 : bar | |
* bar7 : bar | |
* bar8 : bar | |
* bar9 : bar | |
* bar10 : bar | |
* bar11 : bar | |
* | |
*/ | |
class Foo | |
{ | |
const COUNT_PROPERTIES = 12; | |
public $bar; | |
public function __construct($_bar) { $this->bar = $_bar; } | |
public function __get($prop) { | |
switch ($prop) { | |
case 'bar1': return $this -> bar; | |
case 'bar2': | |
return $this | |
-> bar; | |
break; | |
case 'bar3': | |
return $this | |
-> | |
bar; | |
case 'bar4': | |
return $this /*Lorem ipsum*/ | |
-> | |
bar; | |
case 'bar5': | |
return $this /*Lorem ipsum*/ | |
-> /*Lorem ipsum*/ | |
bar; | |
case 'bar6': | |
return $this /*Lorem ipsum*/ | |
-> /*Lorem ipsum*/ | |
bar; /*Lorem ipsum*/ | |
case 'bar7': | |
return $this/*Lorem ipsum*/->/*Lorem ipsum*/bar/*Lorem ipsum*/; | |
case 'bar8': | |
return ${"this"}/*Lorem ipsum*/->/*Lorem ipsum*/bar/*Lorem ipsum*/; | |
case 'bar9': | |
return ${"this"}/*Lorem ipsum*/->/*Lorem ipsum*/{"bar"}/*Lorem ipsum*/; | |
case 'bar10': | |
return @${"this"}/*Lorem ipsum*/->/*Lorem ipsum*/{bar}/*Lorem ipsum*/; | |
case 'bar11': | |
return @${"this"}/*Lorem ipsum*/->/*Lorem ipsum*/{implode(array('b','a','r'))}/*Lorem ipsum*/; | |
/** | |
* stop! You got nothing better to do? | |
**/ | |
default: return $this->bar; | |
} | |
} | |
} | |
$foo = new Foo("bar"); | |
for ($i=0; $i < Foo::COUNT_PROPERTIES; $i++) echo str_pad('bar' . $i, 6, ' ') . ' : ' . $foo->{'bar' . $i} . "\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment