FAQ PHP & Development

How to check which PHP version your site uses

A one-line PHP script and the PHP settings screen in your control panel both show the exact version your site runs on.

Updated 3 min read Beginner

There are two reliable ways to see which PHP version a site is actually running: a tiny script you upload yourself, and the PHP settings screen in your control panel. The second is usually faster, but the first is the one that tells you the truth if the two ever disagree — which happens more often than you would expect when a site has more than one PHP handler available to it.

Method 1: a one-line script

Create a plain text file named version.php, put this single line in it, and upload it to your site's document root:

<?php phpinfo();

Visit yourdomain.com/version.php in a browser and the version number is printed in large text near the top of the page, along with every loaded extension and every current ini setting below it. This is the version PHP itself reports for requests to that folder, which is the only version that actually matters if you are troubleshooting a compatibility problem.

Delete the file when you are done

phpinfo() lists configuration detail that is useful to an attacker as well as to you — file paths, loaded modules, sometimes environment values. Remove version.php as soon as you have read what you needed, rather than leaving it sitting on a live site indefinitely.

Method 2: the control panel

The PHP settings area of your control panel shows the version assigned to the site without you needing to upload anything. This is the quicker check day to day, and it is also where you go if the number needs to change — see upgrading PHP safely for that.

From the command line

If your plan includes SSH access, connecting and running the following gives you the version the shell uses, which can differ from the version serving web requests on some setups:

php -v

For a shared hosting account this is a useful sanity check rather than the primary method — the web-facing version from method 1 is the one your visitors and your application actually experience.

Why the two checks can disagree

A control panel can list one PHP version as the account default while an individual site, subdomain or folder has been switched to a different one, and the command-line PHP binary used over SSH is occasionally a separate build again. If a script behaves as though it is running an older version than the panel claims, trust phpinfo() over anything else — it reports what actually executed the request, not what a setting says should have.

Once you know what you are running, check which version you should be on and, if it is time to move, follow the steps in our guide to upgrading PHP without breaking anything.

Related reading