Search Google for quines. Here's the Wikipedia article.
Update: The key to understand how your program works is the printf documentation. Here's the content of the $body variable:
$body = %c%s%c; printf($body,34,$body,34);
And now let's see what the printf invocation below does:
printf($body,34,$body,34);
The first argument, $body, is the format string. The following arguments, 34, $body, 34 will be interpolated according to format conventions. Second and fourth arguments (34 and 34) are treated as ascii character codes and the corresponding character, double-quotes, will be interpolated in the place of %c's. Third argument of printf will be interpolated as a string in the place of the %s. Therefore, the output will be equivalent to the concatenation of the following strings:
' $body = ' . chr(34) . $body . chr(34) . '; printf($body,34,$body,34); '
Try printing that and you'll see
In reply to Re: Self-printing program
by calin
in thread Self-printing program
by jpfarmer
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |