[ create a new paste ] login | about

Link: http://codepad.org/D0JUR7Jq    [ raw code | output | fork | 1 comment ]

PHP, pasted on Jan 25:
1
2
3
4
5
6
7
8
9
10
<?php
function factory($plan)
{
	echo str_replace(array_map("chr", array(45, 47, 124, 126, 33)), array("\t", "\n", "'", '"', $plan), $plan);
}

$plan = '<?php/function factory($plan)/{/-echo str_replace(array_map("chr", array(45, 47, 124, 126, 33)), array(~\t~, ~\n~, ~|~, |~|, $plan), $plan);/}//$plan = |!|;//factory($plan);/?>/';

factory($plan);
?>


Output:
1
2
3
4
5
6
7
8
9
10
<?php
function factory($plan)
{
	echo str_replace(array_map("chr", array(45, 47, 124, 126, 33)), array("\t", "\n", "'", '"', $plan), $plan);
}

$plan = '<?php/function factory($plan)/{/-echo str_replace(array_map("chr", array(45, 47, 124, 126, 33)), array(~\t~, ~\n~, ~|~, |~|, $plan), $plan);/}//$plan = |!|;//factory($plan);/?>/';

factory($plan);
?>


Create a new paste based on this one


Comments:
posted by physis on Feb 11
A PHP program that outputs **its own sourcecode**, without any trick, just relying on the information explicit in the sorcecode itself.

This may sound as a logical paradox, but it can be done by using a simple logical theorem:

http://en.wikipedia.org/wiki/Quine_%28computing%29
reply