wddx_packet_start function : wddx_packet_start Network PHP

 
<?php
$months = array ("January", "February", "Marts", "April", "May", "June", "July", "August", "September", "October", "November", "December" );
$sales = array (10, 12, 15, 19, 30, 45, 12, 50, 20, 34, 55, 70 );
$pid = wddx_packet_start ( "report" );
wddx_add_vars ( $pid, "months" );
wddx_add_vars ( $pid, "sales" );
echo wddx_packet_end ( $pid );
?>
  
  

wddx_deserialize function demo : wddx_deserialize Network PHP

 
<?php
$fp = fopen ( "http://localhost/remote.php", "rt" );
if ($fp) {
  $wddx = "";
  while ( ! feof ( $fp ) ) {
    $wddx .= fread ( $fp, 4096 );
  }
  fclose ( $fp );
  $wddx = wddx_deserialize ( $wddx );
  for($m = 0; $m < 12; $m ++) {
    printf ( "The sale in %s was %dn", $wddx ['months'] [$m], $wddx ['sales'] [$m] );
  }
}
?>
  
  

__wakeup() is called by unserialize(). : __wakeup Class PHP

 
<?
class apple {
  var $frozen = 0;
  function ___sleep( ) {
    $this->frozen++;
    return array_keys( get_object_vars( $this) );
  }
  function __wakeup( ) {
      print $this->frozen." time(s)";
  }
}
$app = new apple ( );
$stored = serialize( $app );
print $stored;
$new_app = unserialize( $stored );

?>