class A
{
private $x=100;
private $y=200;
}
$a=new A();
$x=(array) $a;
foreach($x as $key=>$val)
{
echo $x[$key];
}
I have issue with the private variable of Class A.
Class A private variable access outside the class when I do typecasting object to array. It should not be access outside the class. But above example I can access private variable of class A.
Here is the result
100200
How can I resolve this issue?