By comparing 2 parameters phpinfo


I'd like to compare the settings I have on 2 different servers. Both are shared hosting so I don't think I have enough access to do it any other way but programmatically with phpinfo. So now that I have the 2 outputs, I'd like to compare them without examining them manually. Is there an automated way for this?

Also, as a side but related note, I think phpinfo is the output of php.ini. Is this correct?

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)

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 = '';
$config2 = unserialize(file_get_contents($export_script));

$diff = ini_diff($config1, $config2);
<pre><?php print_r($diff) ?></pre>