PEAR logo

PHP_CompatInfo : The Definitive Guide

Name

PHP_CompatInfo::parseString — Parse a string

Synopsis

    require_once 'PHP/CompatInfo.php';
   
Array PHP_CompatInfo::parseString( $string,  
  $options = array());  
string   $string;
array   $options = array();

Description

Parse a string for its compatibility info

Parameter

string $string

PHP Code to parses

array $options

An array of options where:

  • debug Contains a boolean to control whether extra ouput is shown.

  • ignore_functions Contains an array of functions to ignore when calculating the version needed.

  • ignore_constants Contains an array of constants to ignore when calculating the version needed.

  • ignore_extensions Contains an array of php extensions to ignore when calculating the version needed.

  • ignore_versions Contains an array of php versions to ignore when calculating the version needed.

  • ignore_functions_match Contains an array of function patterns to ignore when calculating the version needed.

  • ignore_extensions_match Contains an array of extension patterns to ignore when calculating the version needed.

  • ignore_constants_match Contains an array of constant patterns to ignore when calculating the version needed.

Throws

throws no exceptions thrown

See

see PHP_CompatInfo::parseData

Since

since version 0.7.0 (2004-03-09)

Note

This function can not be called statically.

Return value

array - a hash which contains information keys: ignored_functions, ignored_extensions, ignored_constants, max_version, version, extensions, constants, tokens, cond_code

Example

  1. <?php
  2. require_once 'PHP/CompatInfo.php';
  3.  
  4. $pci = new PHP_CompatInfo();
  5.  
  6. $input = '<?php
  7. $nl = "\n";
  8. echo "$nl Rfc3339 = " . DATE_RFC3339;
  9. echo "$nl RSS     = " . DATE_RSS;
  10. ?>';
  11.  
  12. $res = $pci->parseString($input);
  13.  
  14. var_export($res);
  15. ?>

We get such result.

array (
  'ignored_functions' =>
  array (
  ),
  'ignored_extensions' =>
  array (
  ),
  'ignored_constants' =>
  array (
  ),
  'max_version' => '',
  'version' => '5.1.3',
  'extensions' =>
  array (
  ),
  'constants' =>
  array (
    0 => 'DATE_RFC3339',
    1 => 'DATE_RSS',
  ),
  'tokens' =>
  array (
  ),
  'cond_code' =>
  array (
    0 => 0,
    1 =>
    array (
      0 =>
      array (
      ),
      1 =>
      array (
      ),
      2 =>
      array (
      ),
    ),
  ),
)
   

That means we need PHP 5.1.3 minimum to run this chunk of code, due to usage of DATE_RFC3339 constant.

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