Thursday, April 2, 2009

Variable functions with variable variables.

Was playing around with the idea - came out with this. Try reading it and figuring out what it does.

function test($string)
{
print($string);
}
$bar = "test";
$foo = "bar";
$string = "foo";
$$$string("bla");
?>

Output : bla

Essentially, what we're doing is this : I give up explaning. But it's using variable variables to call a variable function. $$$string calls $$foo which calls $bar("bla")
$$($string) = $$foo
$($foo) = $bar
$bar = test("bla")

You get the point.
Sheer awesomeness - although this is a horrible example.

No comments: