How to check PHP version on Ubuntu

Run the following command to get the version of PHP installed on Ubuntu machine:

php -version

The output should look like this:

PHP 7.4.3 (cli) (built: Mar  2 2022 15:36:52) ( 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

Above, 7.4.3 is the version of PHP installed.