PHP Version
If you want to check the PHP version of a script from within the script (printing that value in real time) you can use the phpversion() function like
$version = phpversion()
print($version)
However, for best practices it is advised to use the constant PHP_VERSION as there is no function call, and thus no function overhead — in many situations this will be the preferred method as it is cleaner and more economical.
$version = PHP_VERSION
print($version)
phpinfo() function
The phpinfo() function returns information about how PHP is specifically configured on that machine, if you need more detailed information than just the version. [2]
Resources
- “How to get the PHP Version.” Alex. StackOverflow. <https://stackoverflow.com/questions/2113955/how-to-get-the-php-version>. Accessed 14 Aug 2024.
- “PHP version”. PHP. <https://www.php.net/manual/en/function.phpversion.php> Accessed 14 Aug 2024.
Cite This Article
MLA
West, Brandon. "PHP Version". Projeda, August 14, 2024, https://www.projeda.com/php-version/. Accessed May 2, 2025.
Projeda © 2025