Created
February 18, 2016 07:29
-
-
Save lakinmohapatra/760892e5bbea85f71614 to your computer and use it in GitHub Desktop.
Automated js/css files versioning in php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if (! function_exists('version')) { | |
/** | |
* Used to add file modified time for versioning css/js files. | |
* | |
* @param String $filePath - physical path of file. | |
* @return String FilePath | |
*/ | |
function version($filePath = '') | |
{ | |
if (file_exists($filePath)) { | |
return $filePath . '?version=' . filemtime($filePath); | |
} | |
return $filePath; | |
} | |
} | |
?> | |
<script type='text/javascript' src="<?php echo base_url(version('assets/js/Main.js')); ?>" ></script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks Debasis for your comment :) . Will add clearstatcache() in order to clear stat cache.