Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the PHP version from the source code?

Tags:

shell

php

I'm trying to create a bash script which downloads the latest version of PHP from Github (master branch) and install it.

I would like to create a folder with the version I'm downloading (e. g. /path/to/php/5.4.0) but I cannot find any file among the source code saying "hey, I am the XXX version of PHP". Look below what my simple code does:

url="https://github.com/php/php-src/tarball/master"
curl -L $url > php-temp.tar.gz
tar -zxf php-temp.tar.gz
cd php-php-src*

I was wondering to cat|grep some VERSION or README file but I could not find any references to PHP version among them.

Does someone knows where there is a file which this information?

like image 353
romulodl Avatar asked Dec 05 '25 02:12

romulodl


1 Answers

The file main/php_version.h has the information you are looking for:

For example (https://github.com/php/php-src/blob/master/main/php_version.h):

/* automatically generated by configure */
/* edit configure.in to change version number */
#define PHP_MAJOR_VERSION 5
#define PHP_MINOR_VERSION 5
#define PHP_RELEASE_VERSION 0
#define PHP_EXTRA_VERSION "-dev"
#define PHP_VERSION "5.5.0-dev"
#define PHP_VERSION_ID 50500
like image 196
drew010 Avatar answered Dec 06 '25 15:12

drew010



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!