开发者

PHP: Detect required version

How could I detect which version of PHP my PHP script requires? The general version like PHP5 or PHP4 could I know myself, but there are some function which are added not in the minor 开发者_开发知识库relase.


One of the ways is:

if (!function_exists('function_name')) {
    // the PHP version is not sufficient
}


Use phpversion() . Also, you can use it to tell the version of an extension, with an optional parameter, phpversion([ string $extension ])

PHP manual entry


Here’s a list of the functions that had been added in what version.


Today I found eventual a script/solution that fits: PHP_CompatInfo (PEAR)


Pretty much this falls on you, as the developer, knowing what functions you are using and whether they are very new and require newer versions of PHP to run or not. All it takes is one function introduced in a newer version of PHP to make it only as compatible with that version and newer.


you can put your code or class to the input here: online php shell

then check the '+ unsupported versions' checkbox and click the eval() button. based on the results you will se which versions of php had problems with your code.

example i received because of namespaces:

Output for 4.4.2 - 4.4.9, 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_STRING in /in/s3EIj on line 9
Process exited with code 255.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜