Last active
March 15, 2018 18:09
-
-
Save GusAntoniassi/46f4d113bcbe82fb3b618d0f2d348fbb to your computer and use it in GitHub Desktop.
Getting a server's configuration parameters in .ini format
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Run this script to get a server's configuration parameters in .ini format | |
* Keywords: ini_get ini_get_all function php get configuration data from php.ini format like config | |
*/ | |
$ini = (ini_get_all()); | |
foreach ($ini as $name => $item) { | |
$val = $item['global_value']; | |
$prefix = ''; | |
$suffix = ''; | |
$hasQuotes = false; | |
if (!is_numeric($val)) { | |
if (!empty($val)) { | |
$hasQuotes = true; | |
} else { | |
$val = 'Off'; | |
} | |
} | |
// Prevent quotes from values such as "128K", "1024M" "3G" | |
if (preg_match('/\d+[KMG]/', $val)) { | |
$hasQuotes = false; | |
} | |
if ($hasQuotes) { | |
$prefix = '"'; | |
$suffix = '"'; | |
} | |
echo $name . ' = ' . $prefix . $val . $suffix . '<br/>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment