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

Answer from alex on Stack Overflow
🌐
Reddit
reddit.com › r/phphelp › how to check php version?
r/PHPhelp on Reddit: How to check PHP version?
November 4, 2023 -

hi, I'm new to PHP.

I want to change display_errors to On for debugging, but see many PHP versions installed.

I thought going to http://localhost/first/index.php?language=English&page=phpinfo would give me the version , but it just renders the regular index page.

Ty.

🌐
PHP
php.net › manual › en › function.phpversion.php
PHP: phpversion - Manual
It's defined as used in the above * expression: * * $version_id = $major_version * 10000 + $minor_version * 100 + $release_version; * * Now with PHP_VERSION_ID we can check for features this PHP version * may have, this doesn't require to use ...
🌐
cPanel & WHM
docs.cpanel.net › ea4 › php › how-to-locate-and-install-a-php-version-or-extension
How to Locate and Install a PHP Version or Extension | cPanel & WHM Documentation
January 28, 2026 - Use WHM’s MultiPHP Manager interface (WHM » Home » Software » MultiPHP Manager). This interface allows you to see and change a user’s default PHP version.
🌐
PhoenixNAP
phoenixnap.com › home › kb › sysadmin › how to check php version
How to Check PHP Version | phoenixNAP KB
December 9, 2025 - For this tutorial, we used Display PHP Version, which shows the PHP version in the At a Glance section on the Dashboard: ... This article showed the common ways to check the PHP version on your server, local machine, or WordPress website.
🌐
HostGator
hostgator.com › help › article › what-version-of-php-are-you-using
What Version of PHP Are You Using?
Notes: * PHP upgraded to 8.2 as the default PHP version in June 2023. **As we upgrade our Customer Portal to an optimized and easy-to-use design, Reseller hosting is no longer offered by HostGator for new signups.
Find elsewhere
🌐
DreamHost
help.dreamhost.com › hc › en-us › articles › 214895287-Viewing-your-site-s-PHP-version-and-settings
Viewing your site's PHP version and settings – DreamHost Knowledge Base
OverviewThe following explains how to use a phpinfo.php file to view the version of PHP your site is running.You can view the PHP version of your websites within the panel by navigating to the Man...
🌐
SiteGround
siteground.com › kb › how_to_check_which_php_version_is_running_on_my_account
How to check which PHP version is running on my account? - SiteGround KB
April 12, 2024 - To check exactly which PHP version is used for a certain website, create a simple PHP info file (for example systeminfo.php) in the /home/customer/www/yourdomainname.com/public_html folder, containing the following code:
🌐
Bitnami
docs.bitnami.com › aws › infrastructure › lamp › administration › phpinfo
Check PHP configuration
February 6, 2026 - Save the file as phptest.php in the Web server document root (/opt/bitnami/apache/htdocs/ for Apache or /opt/bitnami/nginx/html for NGINX). Make sure the Web server is running, open a browser and type http://SERVER-IP/phptest.php. You should then see a screen showing detailed information about ...
🌐
Hostinger
hostinger.com › home › support › php › php versions › how to check the php version in hostinger
How to Check the PHP Version in Hostinger - Hostinger Help Center
December 16, 2025 - To check the PHP version of your website, go to the Websites section and click on Dashboard next to the website in question.
🌐
weDevs
wedevs.com › blog › 409582 › how-to-update-php-version
How to Safely Update PHP Version in WordPress Without Breaking It - weDevs
August 11, 2025 - After clicking on the option, it takes you to a new page. It shows you the PHP version your WordPress site is running on. Alternatively, you can install a WordPress plugin to check the PHP version.
🌐
WP Rocket
wp-rocket.me › home › blog › page speed and caching › how to check and update your wordpress php version easily
How to Check and Update Your WordPress PHP Version Easily
January 19, 2026 - PHP version 7.4 or greater. MySQL version 8.0 or greater (ask your host). MariaDB version 10.5 or greater (ask your host). 🧩 Compatibility hack #2: Before installing a new plugin, check which PHP version you should have before downloading it.
🌐
WP Engine
wpengine.com › home › resources › how to check which version of php you’re using
How to Check Which Version of PHP You're Using
September 28, 2024 - While the Site Health Status page ... which version of PHP you’re using by navigating to the Tools > Site Health > Info page in the WordPress dashboard and opening the Server tab....
🌐
Cyfuture Cloud
cyfuture.cloud › kb › general › how-do-i-check-php-version-and-configuration
How Do I Check PHP Version And Configuration?
The phpinfo() function provides comprehensive details about the PHP environment. It includes version, build date, configuration options, extensions, and more.
🌐
Beyond GTA Inc.
beyondgta.com › post › the-impact-of-php-version-and-how-to-check-it
The Impact of PHP Version and How to Check it
May 21, 2024 - Using an old version of PHP can lead to security vulnerabilities and other issues. Here's how you can check your PHP version.How to Check Your PHP Versionphp -vIf you see version information like the following, you're good to go.PHP 8.2.1 (cli) (built: Jan 11 2023 07:28:38) (NTS) Copyright (c) The PHP Group Zend Engine v4.2.1, Copyright (c) Zend Technologies with Xdebug v3.2.2, Copyright (c) 2002-2023, by Derick RethansYou might think, "I already know this command, but it's not showing me the ve
🌐
eUKhost
eukhost.com › home › how to check your php version via ssh
How to check your PHP version via SSH - eukhost
July 3, 2024 - Multiple PHP Versions– If your server supports multiple PHP versions, you may need to specify the path to the PHP binary. For example: ... This command will display the loaded configuration files and directories. PHP Information Page: For a more comprehensive view of your PHP configuration, you can create a phpinfo.php file in your web directory with the following content: ... Access this file via your web browser to see detailed PHP information. This way, you can check your PHP version via SSH.