-
Notifications
You must be signed in to change notification settings - Fork 7.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: new phpinfo_array()
function
#16560
Comments
What data are you interested in from phpinfo? Some of the critical ones are available as constants at runtime. |
This would be a relatively big change, given |
In my current use-case I'm simply after the "Build Date" (output with to get build date: \ob_start();
\phpinfo(INFO_GENERAL);
$phpInfo = \ob_get_clean();
$phpInfo = \strip_tags($phpInfo);
\preg_match('/Build Date (?:=> )?([^\n]*)/', $phpInfo, $matches);
$buildDate = $matches[1]; Nice to have: |
Nicer to have: $buildDate = PHP_BUILD_DATE; |
On the topic of build date:
^ 111 second discrepency
^ 105 second discrepency |
I believe it's because it just uses
|
ext/standard/info.c | 2 +-
main/main.c | 6 ++++--
main/main.stub.php | 7 +++++++
main/main_arginfo.h | Bin 6887 -> 6966 bytes
main/php.h | 2 ++
5 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/ext/standard/info.c b/ext/standard/info.c
index 8a706ef62e..aa03be761c 100644
--- a/ext/standard/info.c
+++ b/ext/standard/info.c
@@ -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
diff --git a/main/main.c b/main/main.c
index 0b38f303c5..0f422fd397 100644
--- a/main/main.c
+++ b/main/main.c
@@ -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
diff --git a/main/main.stub.php b/main/main.stub.php
index b5f848dacc..3359d4a1cd 100644
--- a/main/main.stub.php
+++ b/main/main.stub.php
@@ -34,6 +34,13 @@
* @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
diff --git a/main/main_arginfo.h b/main/main_arginfo.h
index 28a7d15f89..f0d2599baf 100644
Binary files a/main/main_arginfo.h and b/main/main_arginfo.h differ
diff --git a/main/php.h b/main/php.h
index c00777a1b4..0859afca93 100644
--- a/main/php.h
+++ b/main/php.h
@@ -272,6 +272,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
|
I agree with @cmb69 - good suggestion. This def makes more sense. |
Description
phpinfo()
contains a fair amount of information that is only obtainable viaphpinfo()
phpinfo()
outputs as either plain-text or html depending on if called via CLI or web processTo obtain a value, one must wrap phpinfo in
ob_start()
and then parse the text or html that it returns, or extract the specific desired value(s)A new
phpinfo_array()
function that returns the "raw" information would be helpfulreturn
If a single category flag is passed to
phpinfo_array()
, the topmost category level keys could be omittedphpinfo_array(INFO_GENERAL)
return
The text was updated successfully, but these errors were encountered: