开发者

Unsetting attributes of dynamic PHP objects

I have a dynamic class referenced by $row->attributes(), that has some overloaded (dynamic) properties, e.g. $row->attributes()->property1.

I want to unset property1. I've tried $row->attributes()->__unset("property1") and unset($row->attributes()->property1). No joy.

Anyone know how to do this?开发者_开发知识库


It's unclear from the question whether you have used this approach, if you have, I'll remove this answer.

Take a look at __unset, simple example is:

class Foo
{
    public function __unset($property)
    {
        unset($this->__my_property_holder[$property]);
    }
}

You simply need to do unset($row->attributes()->property1), and it will actually invoke Foo->__unset('property1').

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜