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.
}
calling a random method in a class constructor
Moderator: General Moderators
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: calling a random method in a class constructor
Have you tried passing the argument to the constructor?
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Re: calling a random method in a class constructor
awesome thanks.social_experiment wrote:Have you tried passing the argument to the constructor?