-6
Why am I unable to create a function within a class named after the array list of a class method in php?
function $this->info[0](){
}
-6
Why am I unable to create a function within a class named after the array list of a class method in php?
function $this->info[0](){
}
0
There is no way to do this in PHP. The most that can be done is a dynamic method call, but not a statement:
class Aluno {
public function __construct($nome)
{
$this->nome = $nome;
}
public function nome()
{
return $this->nome;
}
}
The call could be made like this:
$aluno = new Aluno('Wallace');
$aluno->{$this->info[0]}();
What you are trying to do, in your example, causes a syntax error.
Browser other questions tagged php classes
You are not signed in. Login or sign up in order to post.
The function name is
$this->info[0]()
? has details missing in your question.– rray
Dude, that’s just scaffolding. PHP is dynamic, but not so much.
– Wallace Maxters
So you don’t get confused with the negatives, understand that the fact that the question is not clear and outside the scope of the site.
– Wallace Maxters