Created
May 29, 2019 19:37
-
-
Save gmemstr/49e7c7ced92a7d5574a84a34f33db49f to your computer and use it in GitHub Desktop.
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 | |
/** | |
* @file | |
* Self-altering PHP counting script. Ideal for lambdas? | |
*/ | |
$count = 3; | |
$thisFile = fopen(__FILE__, 'r'); | |
$thisFileContents = fread($thisFile, filesize(__FILE__)); | |
$thisFileContents = str_replace('$count = ' . $count . ';', '$count = ' . ($count + 1). ';', $thisFileContents); | |
$thisFile = fopen(__FILE__, 'w'); | |
fwrite($thisFile, $thisFileContents); | |
echo $count; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment