From the PHP Manual on phpinfo()
:
Outputs a large amount of information about the current state of PHP. This includes information about PHP compilation options and extensions, the PHP version, server information and environment (if compiled as a module), the PHP environment, OS version information, paths, master and local values of configuration options, HTTP headers, and the PHP License.
phpinfo()
does more than just printing out php.ini
settings.
If you want to process php.ini
settings manually, you might want to check out ini_get_all()
instead of phpinfo()
. This returns an array of all configuration values.
You could transfer the output of ini_get_all()
from server A to server B (for example by using var_export()
to create PHP code to create the array, or serialize()
), then use array_diff_assoc()
to compare the settings.
export.php: (Server A)
<?php echo serialize(ini_get_all()); ?>
compare.php: (Server B)
<?php
function ini_flatten($config) {
$flat = array();
foreach ($config as $key => $info) {
$flat[$key] = $info['local_value'];
}
return $flat;
}
function ini_diff($config1, $config2) {
return array_diff_assoc(ini_flatten($config1), ini_flatten($config2));
}
$config1 = ini_get_all();
$export_script = 'http://server-a.example.com/export.php';
$config2 = unserialize(file_get_contents($export_script));
$diff = ini_diff($config1, $config2);
?>
<pre><?php print_r($diff) ?></pre>