Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions ext/standard/info.c
Original file line number Diff line number Diff line change
Expand Up @@ -805,9 +805,9 @@ PHPAPI ZEND_COLD void php_print_info(int flag)
#ifdef PHP_BUILD_SYSTEM
php_info_print_table_row(2, "Build System", PHP_BUILD_SYSTEM);
#endif
#ifdef PHP_BUILD_PROVIDER
php_info_print_table_row(2, "Build Provider", PHP_BUILD_PROVIDER);
#endif
if (php_build_provider()) {
php_info_print_table_row(2, "Build Provider", php_build_provider());
}
#ifdef PHP_BUILD_COMPILER
php_info_print_table_row(2, "Compiler", PHP_BUILD_COMPILER);
#endif
Expand Down
36 changes: 23 additions & 13 deletions main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
#include "zend_dtrace.h"
#include "zend_observer.h"
#include "zend_system_id.h"
#include "zend_smart_string.h"

#include "php_content_types.h"
#include "php_ticks.h"
Expand All @@ -99,20 +100,30 @@ PHPAPI size_t core_globals_offset;

const char php_build_date[] = __DATE__ " " __TIME__;

PHPAPI const char *php_version(void)
ZEND_ATTRIBUTE_CONST PHPAPI const char *php_version(void)
{
return PHP_VERSION;
}

PHPAPI unsigned int php_version_id(void)
ZEND_ATTRIBUTE_CONST PHPAPI unsigned int php_version_id(void)
{
return PHP_VERSION_ID;
}

ZEND_ATTRIBUTE_CONST PHPAPI const char *php_build_provider(void)
{
#ifdef PHP_BUILD_PROVIDER
return PHP_BUILD_PROVIDER;
#else
return NULL;
#endif
}

PHPAPI char *php_get_version(sapi_module_struct *sapi_module)
{
char *version_info;
spprintf(&version_info, 0, "PHP %s (%s) (built: %s) (%s)\nCopyright (c) The PHP Group\n%s%s",
smart_string version_info = {0};
smart_string_append_printf(&version_info,
"PHP %s (%s) (built: %s) (%s)\n",
PHP_VERSION, sapi_module->name, php_build_date,
#ifdef ZTS
"ZTS"
Expand All @@ -131,16 +142,15 @@ PHPAPI char *php_get_version(sapi_module_struct *sapi_module)
#ifdef HAVE_GCOV
" GCOV"
#endif
,
#ifdef PHP_BUILD_PROVIDER
"Built by " PHP_BUILD_PROVIDER "\n"
#else
""
#endif
,
get_zend_version()
);
return version_info;
smart_string_appends(&version_info, "Copyright (c) The PHP Group\n");
if (php_build_provider()) {
smart_string_append_printf(&version_info, "Built by %s\n", php_build_provider());
}
smart_string_appends(&version_info, get_zend_version());
smart_string_0(&version_info);

return version_info.c;
}

PHPAPI void php_print_version(sapi_module_struct *sapi_module)
Expand Down
11 changes: 9 additions & 2 deletions main/php_main.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,20 @@ BEGIN_EXTERN_C()
* extensions which want to know the version of PHP at run-time, rather than
* the version they were built with at compile-time.
*/
PHPAPI const char *php_version(void);
ZEND_ATTRIBUTE_CONST PHPAPI const char *php_version(void);

/* Returns the PHP version id the engine was built with. This is useful for
* extensions which want to know the version of PHP at run-time, rather than
* the version they were built with at compile-time.
*/
PHPAPI unsigned int php_version_id(void);
ZEND_ATTRIBUTE_CONST PHPAPI unsigned int php_version_id(void);

/* Returns the build provider specified at build time. NULL is returned if
* no build provider was specified. This is useful for extensions which want
* to know the origin of a PHP binary at run-time, for example to provide
* statistics.
*/
ZEND_ATTRIBUTE_CONST PHPAPI const char *php_build_provider(void);

/* Prints the PHP version string for the -v option. It's in main/ so that
* it can be shared between SAPIs.
Expand Down
Loading