Example scenario
Root folder
- ClassA.php
- ClasseB.php
- index.php
File: classeA.php
class ClasseA
{
public $retorno = null;
public $error = "Erro desconhecido";
function __construct
{
$this -> func_A();
}
public function func_A()
{
require_once 'classeB.php';
$obj = new ClasseB;
$obj -> func_B();
}
}
File: classeB.php
class ClasseB extends ClasseA
{
public function func_B()
{
$this -> error = "Erro em func_B";
}
}
File: index.php
require_once 'ClasseA.php';
$obj = new ClasseA;
echo ($obj -> retorno != null) ? $obj -> retorno : $obj -> error;
Problem
My return from index.php
is: "Unknown error".
What I expected: "Error in func_B".
Doubt
- Why does
error
property ofClasseA
not change? - What possible solutions?