Skip to content

Instantly share code, notes, and snippets.

@igorw
Created May 5, 2014 18:28
Show Gist options
  • Save igorw/4316810f8875f7e18b24 to your computer and use it in GitHub Desktop.
Save igorw/4316810f8875f7e18b24 to your computer and use it in GitHub Desktop.
Self-modifying quasi-quine. Try running it, then piping the output into PHP. Then piping that output into PHP again. Then piping that output into PHP again. Then piping that output into PHP again. Then piping that output into PHP again. Then piping that output into PHP again.
<?php
$data = <<<'DATA'
$program = <<<PROGRAM
<?php
\$data = <<<'DATA'\n$data\nDATA;
$data
PROGRAM;
$n = 0;
if ($n >= 5) {
echo "OMFG!\n";
} else {
echo str_replace('$n = 0;', '$n = '.($n+1).';', $program);
}
DATA;
$program = <<<PROGRAM
<?php
\$data = <<<'DATA'\n$data\nDATA;
$data
PROGRAM;
$n = 0;
if ($n >= 5) {
echo "OMFG!\n";
} else {
echo str_replace('$n = 0;', '$n = '.($n+1).';', $program);
}
@igorw
Copy link
Author

igorw commented May 6, 2014

@enygma you got it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment