How to Check and print PHP version installed On Linux / Unix Server
You can check the version of PHP installed on a Linux or Unix server by using the following methods:
- From the command line: You can run the following command in your terminal or shell to display the version of PHP installed on the server:
$ php -vrnPHP 7.3.22-1+ubuntu18.04.1+deb.sury.org+1 (cli) Copyright (c) 1997-2021 The PHP GrouprnZend Engine v3.3.22, Copyright (c) 1998-2021 Zend Technologiesrnwith Zend OPcache v7.3.22-1+ubuntu18.04.1+deb.sury.org+1, Copyright (c) 1999-2021, by Zend Technologies - From a PHP script: You can create a simple PHP script to display the version of PHP installed on the server. To do this, create a file named
php_version.phpwith the following contents:<?php echo 'Current PHP version: ' . phpversion(); ?>Then run the script using the following command:
$ php php_version.phprnCurrent PHP version: 7.3.22-1+ubuntu18.04.1+deb.sury.org+1
