I found this question in a php book and i like it , wanted to share ... even if its in php its not really specific to php language ... it's a nice way to make your code very hard to understand ... <?php function myfunction($a, $b = true) { if($a && !$b) { echo "Hello, World!\n"; } } $s = array ( 0 => "my", 1 => "call", 2 => '$function', 3 => ' ', 4 => "function", 5 => '$a', 6 => '$b', 7 => 'a', 8 => 'b', 9 => '' ); $a = true; $b = false; /* Group A */ $name = $s[?].$s[?].$s[?].$s[?].$s[?].$s[?]; /* Group B */ $name(${$s[?]}, ${$s[?]}); ?>
I got this far: function myfunction($a, $b = true) { if($a && !$b) { echo "Hello, World!\n"; } } $s = array ( 0 => "my", 1 => "call", 2 => '$function', 3 => ' ', 4 => "function", 5 => '$a', 6 => '$b', 7 => 'a', 8 => 'b', 9 => '' ); $a = true; $b = false; /* Group A */ $name = $s[9].$s[9].$s[9].$s[9].$s[0].$s[4]; /* Group B */ $name(${$s[1]}, ${$s[9]}); I couldn't understand why it wasn't working though. Param 1 is set, and param 2 isn't set so it boggled me a bit. Took some thinking about those to even get that far, although it's really simple code it's a bit of a mind bender Thanks for posting it though
I have the answer now Only through trial and improvement though $name = $s[9].$s[9].$s[9].$s[9].$s[0].$s[4]; $name(${$s[7]}, ${$s[10]});
$name = $s[9].$s[9].$s[9].$s[9].$s[0].$s[4]; would result in $name = myfunction; $name(${$s[7]}, ${$s[8]}); would result in myfunction($a, $b); And myfunction($a, $b) (a.k.a. myfunction(true, false)) would result in "Hello, World!\n" Hope I got it. Best, Wisher