I had a question I could not solve. Here are the 3 file codes
User.php
class Usuario{
//protected $nome;
public function getNome() {
return $this->nome;
}
public function setNome($nome){
$this->nome = $nome;
}
}
Student.php
class Aluno extends Usuario{
}
index.php
$aluno = new Aluno();
$aluno->setNome($_POST['nome']);
echo $aluno->getNome();
As you can see, the $ name attribute is commented out and the line $aluno->setNome($_POST['nome']);
returns the value of the field filled in on the form. I found this strange because I thought I had to get an undefined variable message or something.
My question is the following, how does the student's name print on the screen normally if the $nome
attribute is commented out?
Connections and other things more are right, just do not put everything to not get too big.