DEV Community

Discussion on: World's Smallest Quine, "Guaranteed"

Collapse
 
cwreacejr profile image
Charles Reace

PHP in 26 bytes:

<?php readfile(__FILE__);
Enter fullscreen mode Exit fullscreen mode
Collapse
 
awwsmm profile image
Andrew (he/him)

Cool! How does this work, though? I'm not very familiar with PHP.

Collapse
 
cwreacejr profile image
Charles Reace

readfile() reads the contents of the specified file and sends them directly to the output buffer.

__FILE__ is a built-in PHP "magic" constant that contains the full path to the current source code file. (If you're inside an include file at that point, then it will be that file, not the "main" file that included it.)

Collapse
 
cwreacejr profile image
Charles Reace

PS: Depending on your PHP configuration, you could shorten it by 3 bytes to...

<? readfile(__FILE__);
Collapse
 
siddharthshyniben profile image
Siddharth

TBH this is not a "real" quine as a quine cant read its own source.