From 54cacfe7812cf6dc8805b24f7ebd268f9fe0a93b Mon Sep 17 00:00:00 2001 From: Levi Morrison Date: Fri, 4 Aug 2023 08:59:13 -0600 Subject: [PATCH] Add php_version and php_version_id PHPAPI funcs Mostly, extensions will use PHP_VERSION and PHP_VERSION_ID respectfully but sometimes they want to grab the version they run against at run- time rather than at compile-time. --- main/main.c | 10 ++++++++++ main/php_main.h | 13 +++++++++++++ 2 files changed, 23 insertions(+) diff --git a/main/main.c b/main/main.c index d918e0b73ae7..5ca23a92dab5 100644 --- a/main/main.c +++ b/main/main.c @@ -96,6 +96,16 @@ PHPAPI size_t core_globals_offset; #define SAFE_FILENAME(f) ((f)?(f):"-") +PHPAPI const char *php_version(void) +{ + return PHP_VERSION; +} + +PHPAPI unsigned int php_version_id(void) +{ + return PHP_VERSION_ID; +} + /* {{{ PHP_INI_MH */ static PHP_INI_MH(OnSetFacility) { diff --git a/main/php_main.h b/main/php_main.h index 40c1b773fd2f..213043b19b18 100644 --- a/main/php_main.h +++ b/main/php_main.h @@ -23,6 +23,19 @@ #include "SAPI.h" BEGIN_EXTERN_C() + +/* Returns the PHP version 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 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); + PHPAPI zend_result php_request_startup(void); PHPAPI void php_request_shutdown(void *dummy); PHPAPI zend_result php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_module);