• PHP_VERSION_ID是如何定义的


    PHP_VERSION_ID是一个整数,表示当前PHP的版本,从php5.2.7版本开始使用的,比如50207表示5.2.7。
    和PHP版本相关的宏定义在文件 phpsrcdir/main/php_version.h里,如下

    // 文件位置: phpsrc/main/php_version.h
    /* automatically generated by configure */
     /* edit configure.in to change version number */
     #define PHP_MAJOR_VERSION 5
     #define PHP_MINOR_VERSION 6
     #define PHP_RELEASE_VERSION 24
     #define PHP_EXTRA_VERSION ""
     #define PHP_VERSION "5.6.24"
     #define PHP_VERSION_ID 50624

    从注释可以看到,文件phpsrcdir/main/php_version.h是在configure后生成的,以下是configure.in下的相关内容:

    dnl 文件位置:phpsrcdir/confiugre.in
      117 #undef PTHREADS
      118 ])
      119
      120 PHP_MAJOR_VERSION=5
      121 PHP_MINOR_VERSION=6
      122 PHP_RELEASE_VERSION=24
      123 PHP_EXTRA_VERSION=""
      124 PHP_VERSION="$PHP_MAJOR_VERSION.$PHP_MINOR_VERSION.$PHP_RELEASE_VERSION$PHP_EXTRA_VERSION"
      125 PHP_VERSION_ID=`expr [$]PHP_MAJOR_VERSION * 10000 + [$]PHP_MINOR_VERSION * 100 +                [$]PHP_RELEASE_VERSION`
      126
      127 dnl Allow version values to be used in Makefile
      128 PHP_SUBST(PHP_MAJOR_VERSION)
      129 PHP_SUBST(PHP_MINOR_VERSION)
      130 PHP_SUBST(PHP_RELEASE_VERSION)
      131 PHP_SUBST(PHP_EXTRA_VERSION)
    ....
    ....
      139 dnl Setting up the PHP version based on the information above.
      140 dnl -------------------------------------------------------------------------
      141
      142 echo "/* automatically generated by configure */" > php_version.h.new
      143 echo "/* edit configure.in to change version number */" >> php_version.h.new
      144 echo "#define PHP_MAJOR_VERSION $PHP_MAJOR_VERSION" >> php_version.h.new
      145 echo "#define PHP_MINOR_VERSION $PHP_MINOR_VERSION" >> php_version.h.new
      146 echo "#define PHP_RELEASE_VERSION $PHP_RELEASE_VERSION" >> php_version.h.new
      147 echo "#define PHP_EXTRA_VERSION "$PHP_EXTRA_VERSION"" >> php_version.h.new
      148 echo "#define PHP_VERSION "$PHP_VERSION"" >> php_version.h.new
      149 echo "#define PHP_VERSION_ID $PHP_VERSION_ID" >> php_version.h.new
      150 cmp php_version.h.new $srcdir/main/php_version.h >/dev/null 2>&1
      151 if test $? -ne 0 ; then
      152   rm -f $srcdir/main/php_version.h && mv php_version.h.new $srcdir/main/php_version.h && 
      153   echo 'Updated main/php_version.h'
      154 else
      155   rm -f php_version.h.new
      156 fi
      157
      158

    由以上可以看到php的版本信息是在configure.in中定义的,
    120-125行
    首先定义了主版本号PHP_MAJOR_VERSION,子版本号PHP_MINOR_VERSION,发布版本号PHP_RELEASE_VERSION,还有PHP_EXTRA_VERSION为空;
    PHP_VERSION由以上的版本号用符号”.”连接起来,也就是我们常见的版本号,如5.6.24;
    PHP_VERSION_ID则是由PHP_MAJOR_VERSION*10000+PHP_MINOR_VERSION*100+PHP_RELEASE_VERSION计算出来的一个5位数的整数,比如50624, 在php内核或者扩展源码里经常用到PHP_VERSION_ID。

    127-131行
    提交给Makefile

    139-156行
    生成文件$phpsrcdir/main/php_version.h

    php内核定义的所有常量:http://php.net/manual/en/reserved.constants.php

    文章地址:PHP_VERSION_ID是如何定义的

    qrcode_for_gh_61c6224cfae9_258

  • 相关阅读:
    MYSQL: 什么是MYSQLD Service
    100 logging模块
    099 hashlib和hmac模块
    098 json和pickle模块
    097 sys模块
    096 os模块
    095 random模块
    094 datetime模块
    093 time模块
    092 模块基础实战之ATM和购物车系统分文件处理
  • 原文地址:https://www.cnblogs.com/beatzeus/p/6087928.html
Copyright © 2020-2023  润新知