class Base
{
protected $a = "a";
public function __set($name, $value)
{
echo "base";
}
}
class Child extends Base
{
private $b = "b";
public function __set($name, $value)
{
if (property_exists(get_parent_class(), $name))
parent::__set($name, $value);
else
echo "child";
}
}
$obj = new Child();
$obj->a = 1;
$obj->b = 1;
here is solution
remember, always when you create child of any class and want to overload __set, you need 1st to check if property is in parent class otherwise it won't work properly