Get php Version Number - Linux Server - ipFail

To find out the current version of php active on the server, there are basically two simple solutions and both use the php command with additional parameters.

1. php + grep + cut
@ php -v | grep ^PHP | cut -d' ' -f2
7.4.13
2. php +  internal constant from php itself
@ php -r 'echo PHP_VERSION;'
7.4.13

Other constants regarding the available PHP version are the following:

PHP_MAJOR_VERSION (int)
PHP_MINOR_VERSION (int)
PHP_RELEASE_VERSION (int)
PHP_VERSION_ID (int)
PHP_EXTRA_VERSION (string)

If you only want the version, without the last digit, you can use the following command:

@  php -r 'echo PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;'
7.4
Tags: , , , ,

One Comment

  1. […] find out the php version, use the following […]

Leave a Reply

Your email address will not be published. Required fields are marked *