I created the follow class PHP ver 5.5
abstract class Model
{
var $id;
private $cName;
private $tName;
public function __construct($id = 0)
{
$this->cName = 'Im cName';
$this->tName = 'Im tName';
}
}
then an extended class
class claseExtend extends Model
{
var $id;
public function hola()
{
$this->id = 1;
return (array) $this;
}
}
if I Execute this:
$obj = new claseExtend() ;
$retHola =$obj->hola();
print_r($retHola);
I was Expecting to get: array(id => 1)
But the output is: array( \u0000Model\u0000cName: => 'Im cName', \u0000Model\u0000tName => 'Im tName')
What Am I doing wrong, or why is this happening if the attributes are private?
¿Why the array cast includes the private properties?
thanks for your help.