Follow this Blog!

Nov 28, 2013

f Comment

How Do I Check PHP Version Without Calling phpinfo() or phpversion()? How Do I use Command Line to Check My PHP Version?

Amazon How do you check PHP version without calling phpinfo()? Is there a way to check my PHP version without using phpversion()? The point is I don't want to create a new PHP file on my web server just to find my PHP engine's version. I just want to find out my PHP version by running some command on my Unix machine.

Solution

If you've installed php5-fpm, run the following Unix command to see the PHP engine's version:
$ php5-fpm --version
PHP 5.5.9-1ubuntu4.9 (fpm-fcgi) (built: Apr 17 2015 11:44:58)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
    with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies
As you can see, the command to show the PHP version is php5-fpm --version. My PHP version is 5.5.9.

If you are on an older PHP platform, you can run php --version or /usr/bin/php5-cgi v to find out your PHP CGI's version, as shown below.
$ php --version
PHP 5.3.2-1ubuntu4.20 with Suhosin-Patch (cli) (built: Jul 15 2013 17:15:36)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
$ /usr/bin/php5-cgi v
Status: 404 Not Found
X-Powered-By: PHP/5.3.2-1ubuntu4.20
Content-type: text/html

No input file specified.
$
As you can see the PHP version is 5.3.2-1ubuntu4.20.

If your php5-cgi is installed elsewhere you need to use that location instead.

Questions? Let me know!
Please leave a comment here!
One Minute Information - by Michael Wen
Find Michael on Google or Facebook
ADVERTISING WITH US - Direct your advertising requests to Michael