__sleep() method is called by serialize() before it packs up the object.
<? class apple { var $flavor="sweet"; var $frozen = 0; function ___sleep( ) { $this->frozen++; return array_keys( get_object_vars( $this) ); } } $app = new apple ( ); $stored = serialize( $app ); print $stored; ?>