Over a million developers have joined DZone.

PHP5 __sleep To Handle Superclasses' Private Members

·
// PHP5 introduces visibility for object/class methods and data members. Latin teen xxxThis can prove problematic when serializing objects because base classes cannot see their parents' private vars, so these can't be serialized. Plus, a base class probably doesn't know about all of its parents' private vars (even its public and protected ones). So, I use this:Porno teens Free Porn! Free SEX! Tv porno 


class Object {
    function __sleep() {
        return array_keys( (array)$this );
    }
}

class BaseClass extends Object {
    private $foo;
    private $dbh; // some resource, like a database handler
    function __sleep() {
        unset($this->dbh);
        return parent::__sleep();
    }
}

class SubClass extends BaseClass {
    private $bar;
    function __sleep() {
        return parent::__sleep();
    }
}

Sitemap Porno teens  
Topics:

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}