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.
-
You could look at your script and search for 'new' PHP functions...Harmen– Harmen2010-01-25 16:32:28 +00:00Commented Jan 25, 2010 at 16:32
-
+1 That’s a good question. Maybe there’s a script out there that can detect that.Gumbo– Gumbo2010-01-25 16:40:54 +00:00Commented Jan 25, 2010 at 16:40
6 Answers
One of the ways is:
if (!function_exists('function_name')) {
// the PHP version is not sufficient
}
2 Comments
Use phpversion() . Also, you can use it to tell the version of an extension, with an optional parameter, phpversion([ string $extension ])
Comments
1 Comment
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.
Comments
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.