XML_Serializer
[ class tree: XML_Serializer ] [ index: XML_Serializer ] [ all elements ]

Source for file serializeObject.php

Documentation is available at serializeObject.php

  1. <?PHP
  2. /**
  3.  * This is just a basic example that shows
  4.  * how objects can be serialized so they can
  5.  * be fully restored later.
  6.  *
  7.  * @author Stephan Schmidt <schst@php.net>
  8.  */
  9.  
  10.     require_once 'XML/Serializer.php';
  11.  
  12.     // this is just to get a nested object
  13.     $pearError = PEAR::raiseError('This is just an error object',123);
  14.     
  15.     $options = array(
  16.                         "indent"         => "    ",
  17.                         "linebreak"      => "\n",
  18.                         "defaultTagName" => "unnamedItem",
  19.                         "typeHints"      => true
  20.                     );
  21.     
  22.     $foo    =   new stdClass;
  23.     $foo->value = "My value";
  24.     $foo->error = $pearError;
  25.     $foo->xml   = "cool";
  26.  
  27.     $foo->obj    = new stdClass;
  28.     $foo->arr   = array();
  29.     $foo->zero  = 0;
  30.     
  31.     $serializer = new XML_Serializer($options);
  32.     
  33.     $result $serializer->serialize($foo);
  34.     
  35.     if$result === true {
  36.         $xml $serializer->getSerializedData();
  37.     }
  38.  
  39.     echo    "<pre>";
  40.     print_rhtmlspecialchars($xml) );
  41.     echo    "</pre>";
  42. ?>

Documentation generated on Mon, 11 Mar 2019 10:15:34 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.