Using with and

  1. <?php
  2. /**
  3.  * Examples for how to use CFPropertyList
  4.  * Create the PropertyList sample.xml.plist by using {@link CFTypeDetector}.
  5.  * This example shows how to get around the limitation of guess() regarding {@link CFDate} and {@link CFData}.
  6.  * @package plist
  7.  * @subpackage plist.examples
  8.  */
  9.  
  10. // just in case...
  11. error_reportingE_ALL );
  12. ini_set'display_errors''on' );
  13.  
  14. /**
  15.  * Require CFPropertyList
  16.  */
  17. require_once(dirname(__FILE__).'/../CFPropertyList.php');
  18.  
  19.  
  20. /*
  21.  * create a new CFPropertyList instance without loading any content
  22.  */
  23. $plist new CFPropertyList();
  24.  
  25. /*
  26.  * import the array structure to create the sample.xml.plist
  27.  * We make use of CFTypeDetector, which truly is not almighty!
  28.  */
  29.  
  30. $structure array(
  31.   'Year Of Birth' => 1965,
  32.   // Note: dates cannot be guessed, it thus has to be specified explicitly
  33.   'Date Of Graduation' => new CFDategmmktime19234306222004 ) ),
  34.   'Pets Names' => array(),
  35.   // Note: data cannot be guessed, it thus has to be specified explicitly
  36.   'Picture' => new CFData'PEKBpYGlmYFCPA=='true ),
  37.   'City Of Birth' => 'Springfield',
  38.   'Name' => 'John Doe',
  39.   'Kids Names' => array'John''Kyra' ),
  40. );
  41.  
  42. $td new CFTypeDetector();  
  43. $guessedStructure $td->toCFType$structure );
  44. $plist->add$guessedStructure );
  45.  
  46.  
  47. /*
  48.  * Save PList as XML
  49.  */
  50. $plist->saveXMLdirname(__FILE__).'/example-create-03.xml.plist' );
  51.  
  52. /*
  53.  * Save PList as Binary
  54.  */
  55. $plist->saveBinarydirname(__FILE__).'/example-create-03.binary.plist' );
  56.  
  57. ?>

Documentation generated on Fri, 01 Jan 2010 21:33:34 +0100 by phpDocumentor 1.4.1