Created
March 18, 2013 20:42
-
-
Save ryanve/5190628 to your computer and use it in GitHub Desktop.
Show source of a PHP file its .txt extension if it exists.
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 | |
# Show source of this file in .txt extension if it exists | |
call_user_func(function() { | |
$txt = __FILE__ . '.txt'; | |
if ( ! file_exists($txt)) | |
return; | |
# update (cache at least 5-min) | |
if (300 < time() - filemtime($txt)) | |
file_put_contents($txt, file_get_contents(__FILE__)); | |
# message | |
$txt = basename($txt); | |
echo "/* PHP source: $txt */\n"; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment