__sleep() method is called by serialize() before it packs up the object. : __sleep « Class « PHP






__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;
?>
  
  








Related examples in the same category

1.Controlling serialization using __sleep() and __wakeUp()