Skip to content

Instantly share code, notes, and snippets.

@seoagentur-hamburg
Created April 25, 2016 11:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seoagentur-hamburg/51ebb155217f55cfff17ad1eb0a6dc98 to your computer and use it in GitHub Desktop.
Save seoagentur-hamburg/51ebb155217f55cfff17ad1eb0a6dc98 to your computer and use it in GitHub Desktop.
Sorgt für die korrekte Versionierung der CSS-Dateien
<?php
/**
* Automatische Versionierung der Dateinamen
* @param [[Type]] $file [[Description]]
* @return [[Type]] [[Description]]
*/
function auto_version($file)
{
if(strpos($file, '/') !== 0 || !file_exists($_SERVER['DOCUMENT_ROOT'] . $file))
return $file;
$mtime = filemtime($_SERVER['DOCUMENT_ROOT'] . $file);
return preg_replace('{\\.([^./]+)$}', ".$mtime.\$1", $file);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment