Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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);
}
@Jonathan50

This comment has been minimized.

Copy link

@Jonathan50 Jonathan50 commented Dec 16, 2015

does this count as a PHP quine?
@Mister-GoodwinLu

This comment has been minimized.

Copy link

@Mister-GoodwinLu Mister-GoodwinLu commented Jul 10, 2017

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