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

Discussions

How to check PHP version?
The URL given is one that works with the script they provide or expect you to write. There's no built-in "magic URL" to show that information with PHP. A HTML page of configuration information can be generated in PHP code using phpinfo() You may also want to pay attention to the top section of phpinfo() output that lists the ini files read, to make sure you're editing the right files. This same information is available on the command line through the following commands: php -i (full information similar to phpinfo()) php -m (enabled modules / extensions) php -v (version) php --ini (ini files read) See also php --help for more command-line options. Note that you can also set most ini settings at runtime in a script using ini_set() . In this specific case see also the error_reporting() function. More on reddit.com
🌐 r/PHPhelp
6
1
November 4, 2023
Is it difficult/risky to update php version?
Depends on if php has any compatability-breaking changes from 7.2 to 8.2, if it does, the code may need some minor alterations to it. More on reddit.com
🌐 r/linuxquestions
9
3
November 30, 2023
Should I update from PHP 7.4 ?
PHP versions below 8.1 are no longer being supported ( https://php.watch/versions ) i.e. if a bug or vulnerability is discovered in 7.4 or 8, it ain't getting fixed. There's not really any reason to NOT upgrade. Recent versions offer performance improvements. You should always be running up to date WP, theme and plugins anyway - if you're running a plugin or theme that requires php 7.4, it's just a matter of time until you're hacked, because the theme/plugin isn't getting patched. More on reddit.com
🌐 r/Wordpress
21
5
December 13, 2024
PHP-Update from 7.4 to 8.1/8.2 - How much you charge?
If I am the one providing the hosting or the clients pay for maintenance on a monthly basis, I charge nothing because it takes less than 1 min to do this. Charging them 1h for 1min of work it is absolutely gross. If there are any errors after changing the php version, then I change it back and let them know their website needs some work. More on reddit.com
🌐 r/Wordpress
16
5
February 11, 2024
🌐
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.
Find elsewhere
🌐
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.
🌐
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
December 10, 2024 - 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.