PHP_VERSION_ID是如何定义的
2016-11-22 09:38
225 查看
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中定义的,
20-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是如何定义的
和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中定义的,
20-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是如何定义的
相关文章推荐
- PHP_VERSION_ID是如何定义的
- 使用PHP如何获取WSDL中定义的方法列表
- 多行文本如何定义,PHP5.3之后多行定义文本的新特性
- dede5.7定义文件名“{pinyin} 拼音+文章ID”如何去掉文章ID,只显示拼音?
- 如何让没有定义的php变量不报错
- eclipse 4.2.0的安装如何更改jdk环境变量(name=Eclipse Platform id=org.eclipse.platform version=4.2.0)
- PHP中如何定义类及其成员属性与操作
- php如何定义数组常量
- php const和define的区别(php类中如何定义常量)
- PHPCMS v9里面,推荐位ID【posid】的值是如何确定的?是自定义的还是官方定义好的?
- php const和define的区别(php类中如何定义常量)
- PHP扩展开发与内核应用阅读笔记---php的作用域以及如何在扩展中定义,查找php变量
- PHP中如何定义和使用常量
- PHP中如何定义和使用常量
- PHP如何获取最后插入数据的auto_id
- **关于PHP如何定义一个空对象(REST API如何处理空对象和空数组)
- 如何判断平台工具集去做条件编译(VC++目录、预处理器定义、$(PlatformToolsetVersion))
- php大力力 [020节]mysql数据库唯一id字段如何设置
- 如何使用 TP中的公共函数 (定义在common/common.php中的函数)
- [小技巧]如何获取php一个类中定义的常量