Is there a way to check the version of PHP that executed a particular script from within that script? So for example, the following snippet
$version = way_to_get_version(); print $version;
would print 5.3.0 on one machine, and 5.3.1 on another machine.
The most reliable way of finding out what version of PHP is used for that specific website is to use the phpinfo() function, which prints various information about the PHP server, including its version. Once you find out what PHP version you have, either remove the file or restrict the access to it.
$version = phpversion(); print $version;
Documentation
However, for best practice, I would use the constant PHP_VERSION
. No function overhead, and cleaner IMO.
Also, be sure to use version_compare()
if you are comparing PHP versions for compatibility.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With