Skip to content

Instantly share code, notes, and snippets.

@susanBuck
Last active April 10, 2024 13:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save susanBuck/17d9c88ab845bbb6f088e48d1cd56435 to your computer and use it in GitHub Desktop.
Save susanBuck/17d9c88ab845bbb6f088e48d1cd56435 to your computer and use it in GitHub Desktop.
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