Calling a changing function name on an object with PHP : how?
<p>How would I do something like this :</p>

<pre><code>class Test
{

    public function test($methodName) {
     $this-&gt;$methodName;
    }

    private function a() {
     echo("a");
    }

    private function b() {
     echo("b");
    }

}

$testObj = new Test();
$testObj-&gt;test("a()");
$testObj-&gt;test("b()");
</code></pre>

<p>Maybe I should just pass a parameter "TYPE" and use a "IF statement" but I'm just curious! :)</p>

<p>And what if the "dynamic function name" has one or more parameters? </p>

<p>UPDATE : Thanks everyone! :)</p>

<p><strong>UPDATE #2 - Answer :</strong> </p>

<pre><code>class Test
{

    public function testOut($methodName) {
        $this-&gt;$methodName();
    }

    private function a() {
        echo("a");
    }

    private function b() {
        echo("b");
    }

}

$testObj = new Test();
$testObj-&gt;testOut("a");
$testObj-&gt;testOut("b");
</code></pre>

<p>The problem with the class is that there was a method named "Test" (the same as the class name)... I changed it and it worked.</p>
