Check the PHP version with WP-CLI, and why it can differ from your website’s

By CompatNav · Published · Last reviewed · 3 min read

Short answer

wp --info (or wp cli info) prints a line PHP version: the PHP that runs WP-CLI on the command line. Your website can run a different version, because the command line and the web server don’t have to use the same PHP. The version your website runs is in Tools → Site Health → Info → Server, or in your hosting panel. For a PHP compatibility check from the command line, CompatNav Pro, launching on 31 October 2026, adds wp compatnav-pro scan, which compares with the website’s PHP version, never the command line’s.

The command

wp --info, or its long form wp cli info (WP-CLI documentation), prints details about WP-CLI and the PHP it runs on. Run on our test site with the official PHP 8.4 build:

Terminal · WP-CLI 2.12.0 on our test site, run with the official PHP 8.4 build; only the version lines are shown

$ wp --info
PHP version:	8.4.26
WP-CLI version:	2.12.0

The output also names the PHP binary, the php.ini file in use and the operating system. Asking PHP directly gives the same answer, without loading WordPress:

Terminal · WP-CLI 2.12.0 on our test site, same PHP 8.4 build

$ wp eval 'echo PHP_VERSION;' --skip-wordpress
8.4.26

Why it can differ from your website’s

WP-CLI runs with the PHP that starts it on the command line. Your website runs with the PHP the web server is set to, the one you choose in the hosting panel. The two don’t have to match.

We ran the same WordPress installation and the same WP-CLI 2.12.0 with two official PHP builds: wp --info said 7.4.33 with one and 8.4.26 with the other. In an earlier test, WP-CLI answered 8.2.29 while Site Health showed 8.5.11 for the same website (checking many client sites). Nothing was wrong in either case; WP-CLI simply reports its own PHP.

For a PHP upgrade, the version that counts is the website’s.

The website’s PHP version

In the site’s WordPress admin, Tools → Site Health → Info → Server, the row PHP version (wordpress.org):

WordPress admin, Tools → Site Health, Info tab, Server section open: the row “PHP version” reads 8.5.11.
The website’s PHP version, in Site Health.

Or in the hosting panel, where you also change it: checking and changing your PHP version.

Checking PHP compatibility from the command line

Knowing the version is the first half; the second is whether the site’s plugins and theme are ready for the next one. In the WordPress admin, the free CompatNav plugin does that check (Tools → CompatNav): getting started.

For scripts, cron jobs and CI, CompatNav Pro, launching on 31 October 2026, adds WP-CLI commands to the free plugin:

  • wp compatnav-pro scan runs the check from the command line; report prints the last report as a table, JSON, CSV or HTML; findings lists the findings; diff shows what changed since the scan before.
  • Exit codes: 0 safe, 1 will break, 2 files not checked, 3 error, 4 license. A CI job or a deployment script can stop on 1.
  • The right PHP version: the scan compares with the website’s PHP version as CompatNav last saw it, never the command line’s, so the answer above doesn’t trip it up. A --from option sets it by hand.

The scan itself is the free plugin’s: it runs on the server, only reads files and changes nothing. Everything Pro sends, and when, is on what leaves your site.

Key takeaways

  • wp --info and wp cli info show the PHP version of WP-CLI itself.
  • wp eval 'echo PHP_VERSION;' also answers for the command line, not for the website.
  • On our test site, one installation answered 8.2.29 on the command line and 8.5.11 in Site Health.
  • The website’s version: Site Health, or the hosting panel.
  • CompatNav Pro adds wp compatnav-pro scan with exit codes for scripts and CI: 0 safe, 1 will break.

Frequently asked questions

How do I see the website’s PHP version from the command line?

WP-CLI can only report its own PHP. Read the website’s version in Site Health (Tools → Site Health → Info → Server) or in the hosting panel, and note it next to the site in your list.

Which PHP does WP-CLI use?

The one that starts it: usually the php command on the server, whose path wp --info shows on the line PHP binary. Running WP-CLI with another PHP binary changes the answer, as our test shows.

Does the command-line PHP version matter for my site?

For WP-CLI commands and for cron jobs started from the command line, yes. For visitors, no: they get the web server’s PHP.

Check your own site before you upgrade

CompatNav is a free WordPress plugin. It reads the code of your plugins and themes on your own server and tells you, in plain words, what will break and what will only show notices on the PHP version you choose. It never changes your code. It can’t see problems that only appear while code runs with real data, so a quick check of your site after the upgrade still matters.

Get CompatNav on wordpress.org How it works

Sources

About the code examples: each output is the real output of the code shown, run with the official PHP builds, without a php.ini, with all errors reported and displayed. Only the file path was replaced by a neutral server path.