Page 1 of 1

calling a random method in a class constructor

Posted: Sun Nov 06, 2011 2:55 pm
by joevis
Hello, I have about 40 or so functions in a class I created but it won't seem to let me call a random one using a variable in the constructor.

The code looks like this
class superclass {

function __construct() {
$num = rand(1,40);
$name = "fname_" . $num;
superclass::$name
}

function fname_1() {
}

function fname_2() {
}

3,4,5 etc.
}

Re: calling a random method in a class constructor

Posted: Sun Nov 06, 2011 3:19 pm
by social_experiment
Have you tried passing the argument to the constructor?

Re: calling a random method in a class constructor

Posted: Sun Nov 06, 2011 3:25 pm
by joevis
social_experiment wrote:Have you tried passing the argument to the constructor?
awesome thanks.