Created
December 4, 2024 09:14
-
-
Save jaredchu/0fb0dce947b4f7debebdf85ee1c75583 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
/** | |
* Get both the local and master values of a PHP configuration directive. | |
* | |
* @param string $directive The name of the PHP configuration directive (e.g., 'memory_limit'). | |
* @return array Associative array with 'local' and 'master' values. | |
*/ | |
function get_php_config_values(string $directive): array { | |
// Get the local value | |
$local_value = ini_get($directive); | |
// Get all configuration values | |
$all_ini_values = ini_get_all(null, false); | |
// Get the master value or fallback to the local value | |
$master_value = $all_ini_values[$directive]['global_value'] ?? $local_value; | |
return [ | |
'local' => $local_value, | |
'master' => $master_value, | |
]; | |
} | |
// Example usage | |
$memory_limits = get_php_config_values('memory_limit'); | |
echo "Local Memory Limit: {$memory_limits['local']}\n"; | |
echo "Master Memory Limit: {$memory_limits['master']}\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment