mirror of
https://github.com/php/php-src.git
synced 2024-11-23 01:44:06 +08:00
Add PHP_BUILD_DATE constant
This information can be occasionally useful, and would otherwise need to be parsed from `phpinfo()` output. However, maybe more importantly we unify the build date between what is given by `php -v` and `php -i`, since these compilation units are not necessarily preprocessed within the same second. Closes GH-16747.
This commit is contained in:
parent
03cbb3ee58
commit
6dec6a6dba
1
NEWS
1
NEWS
@ -8,6 +8,7 @@ PHP NEWS
|
||||
- Core:
|
||||
. Fixed bug GH-16665 (\array and \callable should not be usable in
|
||||
class_alias). (nielsdos)
|
||||
. Added PHP_BUILD_DATE constant. (cmb)
|
||||
|
||||
- Curl:
|
||||
. Added curl_multi_get_handles(). (timwolla)
|
||||
|
@ -129,6 +129,9 @@ PHP 8.5 UPGRADE NOTES
|
||||
10. New Global Constants
|
||||
========================================
|
||||
|
||||
- Core:
|
||||
. PHP_BUILD_DATE.
|
||||
|
||||
- POSIX:
|
||||
. POSIX_SC_OPEN_MAX.
|
||||
|
||||
|
@ -801,7 +801,7 @@ PHPAPI ZEND_COLD void php_print_info(int flag)
|
||||
php_info_print_box_end();
|
||||
php_info_print_table_start();
|
||||
php_info_print_table_row(2, "System", ZSTR_VAL(php_uname));
|
||||
php_info_print_table_row(2, "Build Date", __DATE__ " " __TIME__);
|
||||
php_info_print_table_row(2, "Build Date", php_build_date);
|
||||
#ifdef PHP_BUILD_SYSTEM
|
||||
php_info_print_table_row(2, "Build System", PHP_BUILD_SYSTEM);
|
||||
#endif
|
||||
|
@ -97,6 +97,8 @@ PHPAPI size_t core_globals_offset;
|
||||
|
||||
#define SAFE_FILENAME(f) ((f)?(f):"-")
|
||||
|
||||
const char php_build_date[] = __DATE__ " " __TIME__;
|
||||
|
||||
PHPAPI const char *php_version(void)
|
||||
{
|
||||
return PHP_VERSION;
|
||||
@ -110,8 +112,8 @@ PHPAPI unsigned int php_version_id(void)
|
||||
PHPAPI char *php_get_version(sapi_module_struct *sapi_module)
|
||||
{
|
||||
char *version_info;
|
||||
spprintf(&version_info, 0, "PHP %s (%s) (built: %s %s) (%s)\nCopyright (c) The PHP Group\n%s%s",
|
||||
PHP_VERSION, sapi_module->name, __DATE__, __TIME__,
|
||||
spprintf(&version_info, 0, "PHP %s (%s) (built: %s) (%s)\nCopyright (c) The PHP Group\n%s%s",
|
||||
PHP_VERSION, sapi_module->name, php_build_date,
|
||||
#ifdef ZTS
|
||||
"ZTS"
|
||||
#else
|
||||
|
@ -34,6 +34,13 @@ const PHP_EXTRA_VERSION = UNKNOWN;
|
||||
* @cvalue PHP_VERSION_ID
|
||||
*/
|
||||
const PHP_VERSION_ID = UNKNOWN;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @cvalue php_build_date
|
||||
*/
|
||||
const PHP_BUILD_DATE = UNKNOWN;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
* @cvalue PHP_ZTS
|
||||
|
3
main/main_arginfo.h
generated
3
main/main_arginfo.h
generated
@ -1,5 +1,5 @@
|
||||
/* This is a generated file, edit the .stub.php file instead.
|
||||
* Stub hash: 793b455a47a0422cee767ef2f6a448a369520542 */
|
||||
* Stub hash: cb5c9a3e48b18a773264378099267550ca9e4fc1 */
|
||||
|
||||
static void register_main_symbols(int module_number)
|
||||
{
|
||||
@ -9,6 +9,7 @@ static void register_main_symbols(int module_number)
|
||||
REGISTER_LONG_CONSTANT("PHP_RELEASE_VERSION", PHP_RELEASE_VERSION, CONST_PERSISTENT);
|
||||
REGISTER_STRING_CONSTANT("PHP_EXTRA_VERSION", PHP_EXTRA_VERSION, CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("PHP_VERSION_ID", PHP_VERSION_ID, CONST_PERSISTENT);
|
||||
REGISTER_STRING_CONSTANT("PHP_BUILD_DATE", php_build_date, CONST_PERSISTENT);
|
||||
REGISTER_BOOL_CONSTANT("PHP_ZTS", PHP_ZTS, CONST_PERSISTENT);
|
||||
REGISTER_BOOL_CONSTANT("PHP_DEBUG", PHP_DEBUG, CONST_PERSISTENT);
|
||||
REGISTER_STRING_CONSTANT("PHP_OS", PHP_OS_STR, CONST_PERSISTENT);
|
||||
|
@ -265,6 +265,8 @@ END_EXTERN_C()
|
||||
extern char **environ;
|
||||
#endif /* ifndef PHP_WIN32 */
|
||||
|
||||
extern const char php_build_date[];
|
||||
|
||||
#ifdef PHP_PWRITE_64
|
||||
ssize_t pwrite(int, void *, size_t, off64_t);
|
||||
#endif
|
||||
|
8
tests/basic/build_date.phpt
Normal file
8
tests/basic/build_date.phpt
Normal file
@ -0,0 +1,8 @@
|
||||
--TEST--
|
||||
PHP_BUILD_DATE
|
||||
--FILE--
|
||||
<?php
|
||||
var_dump(PHP_BUILD_DATE);
|
||||
?>
|
||||
--EXPECTREGEX--
|
||||
string\(20\) "[A-Za-z]{3} \d{2} \d{4} \d{2}:\d{2}:\d{2}"
|
Loading…
Reference in New Issue
Block a user