PEAR logo

PHP_CompatInfo : The Definitive Guide

Basic usage

The main steps of using any available renderer are quite similar:

  1. <?php
  2. require_once 'PHP/CompatInfo.php';
  3.  
  4. // data source to parse: file, directory, string, ...
  5. $datasource = '/tmp/HTML_CSS-1.5.1';
  6.  
  7. // parser options depending of data source
  8. $options    = array();
  9.  
  10. // kind of renderer: array, csv, html, null, text, xml, ...
  11. $driverType    = 'array';  // case insensitive
  12.  
  13. // specific renderer hash options
  14. $driverOptions = array();
  15.  
  16. $pci = new PHP_CompatInfo($driverType, $driverOptions);
  17. $r = $pci->parseData($datasource, $options);
  18. ?>
[Note] Note

To keep compatibility with previous versions, you can find the result similar to var_export (Array renderer) in $r (in our example). All parse functions (parseDir, parseFile, parseArray, parseString) have the same behavior.

PHP_CompatInfo class constructor expect to receive two parameters: first one identify the kind of renderer (array, csv, html, null, text, xml), while second is private and specific to each renderer. Allows to customize a bit the renderer without to rewrite a new one (explore all options before beginning to write your own version).

PHP_CompatInfo : The Definitive Guide v 1.8.0 : August 1, 2008