How to get the PHP Version?

$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.

Leave a Comment