This example show how to parse a single string (chunk of code) and display results in CSV format with the corresponding renderer rather than the default one (Array).
This example requires mandatory resources :
The very basic script to parse the chunk of code (lines 4 to 19)
"Source code";"Version";"C";"Extensions";"Constants/Tokens" "<?php ... ?>";"5.1.0,5.0.4";"0";"";""
At line 25, we created an instance of PHP_CompatInfo with the renderer type to use (csv) and its default options:
At line 26, we used the parseArray() method because we have pre-set input for it (see line 21). But we also may used the parseString() method with $dataSource = $str1.
In all cases, don't forget to specify the parser option is_string (= true).
On CSV results, we can find an header line, follow by results itself. Of course each column available depend of output-level configuration option (default = 31 : all details).
<?php ... ?> identify a chunk of code analysed, and "C" = 0 (so accuray is at 100%).
Finally, we can tell that the chunk of code (in $str1) need PHP 5.1.0 (minimum) and PHP 5.0.4 (maximum) to run : it's an impossible case (conflict). This script is for the purpose of demonstration of version/max_version only.