Skip to content

Commit 0311e60

Browse files
authored
Add php_version and php_version_id PHPAPI funcs (#11875)
Mostly, extensions will use `PHP_VERSION` and `PHP_VERSION_ID` respectfully but sometimes they want to grab the version at run-time rather than at compile-time. For example, extensions which distribute pre-built binaries may want this.
1 parent 1b092c6 commit 0311e60

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

main/main.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,16 @@ PHPAPI size_t core_globals_offset;
9696

9797
#define SAFE_FILENAME(f) ((f)?(f):"-")
9898

99+
PHPAPI const char *php_version(void)
100+
{
101+
return PHP_VERSION;
102+
}
103+
104+
PHPAPI unsigned int php_version_id(void)
105+
{
106+
return PHP_VERSION_ID;
107+
}
108+
99109
/* {{{ PHP_INI_MH */
100110
static PHP_INI_MH(OnSetFacility)
101111
{

main/php_main.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,19 @@
2323
#include "SAPI.h"
2424

2525
BEGIN_EXTERN_C()
26+
27+
/* Returns the PHP version the engine was built with. This is useful for
28+
* extensions which want to know the version of PHP at run-time, rather than
29+
* the version they were built with at compile-time.
30+
*/
31+
PHPAPI const char *php_version(void);
32+
33+
/* Returns the PHP version id the engine was built with. This is useful for
34+
* extensions which want to know the version of PHP at run-time, rather than
35+
* the version they were built with at compile-time.
36+
*/
37+
PHPAPI unsigned int php_version_id(void);
38+
2639
PHPAPI zend_result php_request_startup(void);
2740
PHPAPI void php_request_shutdown(void *dummy);
2841
PHPAPI zend_result php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_module);

0 commit comments

Comments
 (0)