Aug 27 2008

[PHP] PHP Quine

Category: Articles,PHPFractalizeR @ 4:28 pm

Browing internet, I found the term of “quine” which is the program, that prints it’s exact source code. I was curious, if I am able to write such software. This is what I was able to compose:

<?php
$u='$';
$q="'";
$qq='"';
$s='<?php';
$e='?>';
$w='eval($p);';
$p='echo"$s\r\n{$u}u=$q$u$q;\r\n{$u}q=$qq$q$qq;\r\n{$u}qq=$q$qq$q;\r\n{$u}s=$q$s$q;\r\n{$u}e=$q$e$q;\r\n{$u}w=$q$w$q;\r\n{$u}p=$q$p$q;\r\n$w";';
eval($p);

It is a small and quite simple quine, however, I spent about several hours understanding how quines work and how to write them in PHP 🙂

Tags: ,

Leave a Reply

You must be logged in to post a comment. Login now.