I am not able to create a function inside a class with the name of the array list of a class method in php? [closed]

-6

function $this->info[0](){

}
    
asked by anonymous 04.05.2016 / 16:41

1 answer

0

You can not 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.

    
04.05.2016 / 16:55