![]() PHP_CompatInfo : The Definitive Guide |
PHP_CompatInfo::parseFile
— Parse
a single file
require_once 'PHP/CompatInfo.php';
Array PHP_CompatInfo::parseFile(
|
$file, | |
$options = array()) ;
|
string | $file; |
array | $options = array(); |
$file
Path of File to parse
$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.
array - a hash which contains information
keys: ignored_functions
, ignored_extensions
, ignored_constants
, max_version
, version
,
extensions
, constants
, tokens
,
cond_code
Suppose we have to parse source code like this one, named "conditional.php" :
We get such result.
array ( 'ignored_functions' => array ( 0 => 'simplexml_load_file', ), 'ignored_extensions' => array ( ), 'ignored_constants' => array ( 0 => 'DATE_W3C', ), 'max_version' => '', 'version' => '4.3.10', 'extensions' => array ( 0 => 'date', ), 'constants' => array ( 0 => 'PHP_EOL', 1 => 'DIRECTORY_SEPARATOR', 2 => '__FILE__', 3 => 'DATE_W3C', ), 'tokens' => array ( ), 'cond_code' => array ( 0 => 5, 1 => array ( ), ), )
That means php simple_load_file() function and constant DATE_W3C were ignored from scope, and PHP version minimum to run is 4.3.10 (in such condition)
![]() |
Warning |
---|---|
Of course it is impossible to run such script with only PHP 4.3.10 because usage of DATE_W3C constant is not conditionned. |
PHP_CompatInfo : The Definitive Guide | v 1.8.0 : August 1, 2008 |