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.     error_reporting(E_ALL);
  10.  
  11.     require_once 'XML/Serializer.php';
  12.  
  13.     // this is just to get a nested object
  14.     $pearError = PEAR::raiseError('This is just an error object',123);
  15.     
  16.     $options = array(
  17.                         "indent"         => "    ",
  18.                         "linebreak"      => "\n",
  19.                         "defaultTagName" => "unnamedItem",
  20.                         "typeHints"      => true
  21.                     );
  22.     
  23.     $foo    =   new stdClass;
  24.     $foo->value = "My value";
  25.     $foo->error = $pearError;
  26.     $foo->xml   = "cool";
  27.  
  28.     $foo->obj    = new stdClass;
  29.     $foo->arr   = array();
  30.     $foo->zero  = 0;
  31.     
  32.     $serializer &new XML_Serializer($options);
  33.     
  34.     $result $serializer->serialize($foo);
  35.     
  36.     if$result === true {
  37.         $xml $serializer->getSerializedData();
  38.     }
  39.  
  40.     echo    "<pre>";
  41.     print_rhtmlspecialchars($xml) );
  42.     echo    "</pre>";
  43. ?>

Documentation generated on Mon, 11 Mar 2019 14:19:21 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.