What best practices should be followed when using PHP to manage browser caching for script updates?

When using PHP to manage browser caching for script updates, it is important to set proper cache-control headers to ensure that the browser fetches the latest version of the script when it is updated. This can be achieved by setting the "Cache-Control" header to "no-cache" or by appending a unique version number to the script URL.

<?php
$version = '1.0.0'; // Update this version number when the script is updated

header("Cache-Control: no-cache, must-revalidate");
header("Expires: 0");
?>
<script src="myscript.js?v=<?php echo $version; ?>"></script>