Skip to content

Instantly share code, notes, and snippets.

@mncaudill
Created December 21, 2010 05:19
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mncaudill/749531 to your computer and use it in GitHub Desktop.
Save mncaudill/749531 to your computer and use it in GitHub Desktop.
This is a PHP quine. When run, this program will print out an exact version of itself.
<?php
$data = array(
36,110,108,32,61,32,99,104,114,40,49,48,41,59,10,112,114,105,110,116,32,34,60,63,112,104,112,36,110,108,36,110,108,92,36,100,97,116,97,32,61,32,97,114,114,97,121,40,36,110,108,34,59,10,10,102,111,114,101,97,99,104,40,36,100,97,116,97,32,97,115,32,36,100,41,32,123,10,32,32,32,112,114,105,110,116,32,34,36,100,44,34,59,32,32,10,125,10,10,112,114,105,110,116,32,34,36,110,108,41,59,36,110,108,36,110,108,34,59,10,10,102,111,114,101,97,99,104,40,36,100,97,116,97,32,97,115,32,36,100,41,32,123,10,32,32,32,32,112,114,105,110,116,32,115,112,114,105,110,116,102,40,34,37,99,34,44,32,36,100,41,59,10,125,10,
);
$nl = chr(10);
print "<?php$nl$nl\$data = array($nl";
foreach($data as $d) {
print "$d,";
}
print "$nl);$nl$nl";
foreach($data as $d) {
print sprintf("%c", $d);
}
@jeandrek
Copy link

does this count as a PHP quine?

@Mister-G-Lu
Copy link

how does your code print out "foreach"? I don't see code that prints it out...

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