4
I have the following class:
class Usuario{
private $nome;
private $profissao;
function setNome($nome){
$this->nome = $nome;
}
function getNome(){
return $this->nome;
}
function setProfissao($profissao){
$this->profissao = $profissao;
}
function getProfissao(){
return $this->profissao;
}
}
Here I instate an object
$user = new Usuario();
$user->setNome('Nome Qualquer');
$user->setProfissao('Profissão Qualquer');
I wanted to know how I can list all properties of this Objet using foreach. I already know there is get_object_vars
that already does it for me. But I wanted to use foreach even for that purpose. Of course the above example is just a simple example.
This answer should help you http://answall.com/a/97571/28595
– user28595