I have a user class that does not see protected variable of class that it inherits the code is the following
abstract class Model{
protected $conn;
public function __construct(){
$conn = Connect::getConnection();
}
}
Daughter class
class Usuario extends Model{
public function testaConexao(){
if($this->conn)
return 'sucesso';
else
return 'falha';
}
}
call
$user = new Usuario();
echo $user->testaConexao();
//saida: falha
Generating a log within the Model constructor, the variable $ conn is created and is different from false. But when I try to use it in the child class no longer recognizes, it returns null using $ this-> conn;