Skip to content

Instantly share code, notes, and snippets.

@susanBuck
Last active February 21, 2023 16:04
Embed
What would you like to do?
Output the differences between two PHP config files (php.ini)
<?php
# REF:
# Nginx: https://codewithsusan.com/notes/upgrade-php-nginx
# Apache: https://codewithsusan.com/notes/upgrade-php-apache
# UPDATE THESE TWO PATHS:
$current = '/path/to/current/php.ini';
$previous = '/path/to/previous/php.ini';
$currentSettings = parse_ini_file($current);
$previousSettings = parse_ini_file($previous);
$diffSettings1 = array_diff($previousSettings, $currentSettings);
$diffSettings2 = array_diff($currentSettings, $previousSettings);
$diffSettings = array_merge($diffSettings1, $diffSettings2);
?>
<table>
<tr>
<th>Setting</th>
<th>Previous<br> <?=$previous?></th>
<th>Current <br> <?=$current?></th>
</tr>
<?php foreach($diffSettings as $setting => $value): ?>
<td><?=$setting?></td>
<td><?=$previousSettings[$setting] ?? '[Setting not present]' ?></td>
<td><?=$currentSettings[$setting] ?? '[Setting not present]'?></td>
</tr>
<?php endforeach; ?>
</table>
<style>
body {
font-family:Courier;
}
table {
table-layout: fixed;
width:100%;
border-collapse:collapse;
}
table, th, td {
border: 1px solid;
}
td {
padding:10px;
word-wrap: break-word;
}
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment