![]() PHP_CompatInfo : The Definitive Guide |
Rather than parsing file after file of an application, you may give the root of your application path as the main directory to parse. Default is recursive parsing: that mean each directory children will be also parsed. And only files with extension php, php4, inc, phtml will be proceed.
Suppose we have to detect which PHP version we need to run the PEAR::File_Find package release 1.3.0
First begin to download the archive from http://pear.php.net/package/File_Find/download/1.3.0 and extract the full contents to a temporary directory (in our example its '/tmp')
We will use this very simple detection script.
Results displayed:
array ( 'ignored_files' => array ( 0 => '/tmp/File_Find-1.3.0/package.xml', 1 => '/tmp/File_Find-1.3.0/tests/01glob.phpt', 2 => '/tmp/File_Find-1.3.0/tests/02maptree.phpt', 3 => '/tmp/File_Find-1.3.0/tests/03maptreemultiple.phpt', 4 => '/tmp/File_Find-1.3.0/tests/04search.phpt', 5 => '/tmp/File_Find-1.3.0/tests/05search_inside.phpt', 6 => '/tmp/File_Find-1.3.0/tests/06match_shell.phpt', 7 => '/tmp/File_Find-1.3.0/tests/bug2773.phpt', ), 'ignored_functions' => array ( ), 'ignored_extensions' => array ( ), 'ignored_constants' => array ( ), 'max_version' => '', 'version' => '4.3.0', 'extensions' => array ( 0 => 'pcre', ), 'constants' => array ( 0 => '__FILE__', ), 'tokens' => array ( ), 'cond_code' => array ( 0 => 4, ), '/tmp/File_Find-1.3.0/Find.php' => array ( 'ignored_functions' => array ( ), 'ignored_extensions' => array ( ), 'ignored_constants' => array ( ), 'max_version' => '', 'version' => '4.3.0', 'extensions' => array ( 0 => 'pcre', ), 'constants' => array ( ), 'tokens' => array ( ), 'cond_code' => array ( 0 => 4, ), ), '/tmp/File_Find-1.3.0/tests/setup.php' => array ( 'ignored_functions' => array ( ), 'ignored_extensions' => array ( ), 'ignored_constants' => array ( ), 'max_version' => '', 'version' => '4.0.0', 'extensions' => array ( ), 'constants' => array ( 0 => '__FILE__', ), 'tokens' => array ( ), 'cond_code' => array ( 0 => 0, ), ), )
means that package PEAR::File_Find 1.3.0 need at least PHP 4.3.0 with extension pcre.
![]() |
Caution |
---|---|
If you have a look on source code, you will see that all
conditions referred to private package constant |
![]() |
Tip |
---|---|
You may avoid to read the source code to know the constant
name, if you specify the
|
And you will see in displayed results, something like :
'cond_code' => array ( 0 => 4, 1 => array ( 0 => array ( ), 1 => array ( ), 2 => array ( 0 => 'FILE_FIND_DEBUG', ), ),
cond_code
offset 1 is an array available
only when debug mode is set to true. In this array :
offset 0, give name of function conditions
offset 1, give name of extension conditions
offset 2, give name of constant conditions
PHP_CompatInfo : The Definitive Guide | v 1.8.0 : August 1, 2008 |