Using

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

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