- We’ll start off with the quickest method. Open a command line terminal and type the following command.
$ php -version PHP 7.4.3 (cli) (built: May 26 2020 12:24:22) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies with Zend OPcache v7.4.3, Copyright (c), by Zend Technologies
- What if we want a little more in depth information? You can start a PHP interactive shell (again, from the command line) and use the
phpinfo
function. This will return a ton of information, but will show the PHP version at the top.$ php -a Interactive mode enabled php > phpinfo(); phpinfo() PHP Version => 7.4.3 ... php > exit
- Lastly, we could use the
phpinfo
function again, but inside of a php file. The perk of this method is that all the information will be formatted nicely for us and viewable inside a browser. We have a full guide on how to create a phpinfo.php page, but it basically just involves saving a PHP file with the following line of code and then accessing it from your browser.<?php phpinfo(); ?>
How to check PHP version on Ubuntu
- 521 Users Found This Useful