| 1 |
lars |
1 |
<?php
|
|
|
2 |
/**
|
|
|
3 |
* Get the Compatibility info for a list of chunk of code (strings)
|
|
|
4 |
*
|
|
|
5 |
* This example show the new options|features available with API 1.8.0
|
|
|
6 |
*
|
|
|
7 |
* PHP versions 4 and 5
|
|
|
8 |
*
|
|
|
9 |
* @category PHP
|
|
|
10 |
* @package PHP_CompatInfo
|
|
|
11 |
* @author Laurent Laville <pear@laurent-laville.org>
|
|
|
12 |
* @license http://www.opensource.org/licenses/bsd-license.php BSD
|
|
|
13 |
* @version CVS: $Id: pci180_parsearray_strings.php,v 1.2 2008/07/22 20:26:45 farell Exp $
|
|
|
14 |
* @link http://pear.php.net/package/PHP_CompatInfo
|
|
|
15 |
* @since version 1.8.0b3 (2008-06-07)
|
|
|
16 |
* @ignore
|
|
|
17 |
*/
|
|
|
18 |
|
|
|
19 |
require_once 'PHP/CompatInfo.php';
|
|
|
20 |
|
|
|
21 |
/*
|
|
|
22 |
With all default options, its same as version 1.8.0b1 or less
|
|
|
23 |
No need to specify driver type ('array') and options, in class constructor
|
|
|
24 |
Results display made with PHP::var_export
|
|
|
25 |
*/
|
|
|
26 |
//$compatInfo = new PHP_CompatInfo();
|
|
|
27 |
|
|
|
28 |
/*
|
|
|
29 |
With API 1.8.0 you may choose a custom render,
|
|
|
30 |
between all default renderers (all customizable).
|
|
|
31 |
*/
|
|
|
32 |
$driverType = 'array';
|
|
|
33 |
|
|
|
34 |
/*
|
|
|
35 |
Display wait messages or a progress bar (PEAR::Console_ProgressBar)
|
|
|
36 |
if available while parsing data source
|
|
|
37 |
Default behavior is: silent = true (no wait system)
|
|
|
38 |
*/
|
|
|
39 |
$driverOptions = array('silent' => false, 'progress' => 'text');
|
|
|
40 |
|
|
|
41 |
$compatInfo = new PHP_CompatInfo($driverType, $driverOptions);
|
|
|
42 |
|
|
|
43 |
$str1 = '<?php
|
|
|
44 |
$nl = "\n";
|
|
|
45 |
echo "$nl Atom = " . DATE_ATOM;
|
|
|
46 |
echo "$nl Cookie = " . DATE_COOKIE;
|
|
|
47 |
echo "$nl Iso8601 = " . DATE_ISO8601;
|
|
|
48 |
echo "$nl Rfc822 = " . DATE_RFC822;
|
|
|
49 |
echo "$nl Rfc850 = " . DATE_RFC850;
|
|
|
50 |
echo "$nl Rfc1036 = " . DATE_RFC1036;
|
|
|
51 |
echo "$nl Rfc1123 = " . DATE_RFC1123;
|
|
|
52 |
echo "$nl Rfc2822 = " . DATE_RFC2822;
|
|
|
53 |
echo "$nl RSS = " . DATE_RSS;
|
|
|
54 |
echo "$nl W3C = " . DATE_W3C;
|
|
|
55 |
?>';
|
|
|
56 |
|
|
|
57 |
$str2 = '<?php
|
|
|
58 |
class Request6056
|
|
|
59 |
{
|
|
|
60 |
function testMaxVersion()
|
|
|
61 |
{
|
|
|
62 |
// PHP 5 <= 5.0.4
|
|
|
63 |
$res = php_check_syntax(\'bug6581.php\');
|
|
|
64 |
|
|
|
65 |
$array1 = array(\'blue\' => 1, \'red\' => 2, \'green\' => 3);
|
|
|
66 |
$array2 = array(\'green\' => 5, \'blue\' => 6, \'yellow\' => 7);
|
|
|
67 |
|
|
|
68 |
// PHP 5 >= 5.1.0RC1
|
|
|
69 |
$diff = array_diff_key($array1, $array2);
|
|
|
70 |
}
|
|
|
71 |
}
|
|
|
72 |
?>';
|
|
|
73 |
$source = array($str1, $str2);
|
|
|
74 |
// CAUTION: if you forget this option, you will have no output except a FALSE result (see $r)
|
|
|
75 |
$options = array('is_string' => true);
|
|
|
76 |
|
|
|
77 |
$r = $compatInfo->parseArray($source, $options);
|
|
|
78 |
// You may also use the new unified method parseData(), parseArray() became an alias
|
|
|
79 |
//$r = $compatInfo->parseData($source, $options);
|
|
|
80 |
|
|
|
81 |
/*
|
|
|
82 |
To keep backward compatibility, result is also return (here in $r)
|
|
|
83 |
but you don't need to print it, it's the default behavior of API 1.8.0
|
|
|
84 |
*/
|
|
|
85 |
//var_export($r);
|
|
|
86 |
?>
|