Quine: Difference between revisions

Content deleted Content added
added some comentary
No edit summary
Line 12: Line 12:
* Newlines in the program may have to be reproduced as newlines in the string, which usually requires some kind of escape sequence (e.g. "\n"). This causes the same problem as above, where the escaping character needs to itself be excaped, etc.
* Newlines in the program may have to be reproduced as newlines in the string, which usually requires some kind of escape sequence (e.g. "\n"). This causes the same problem as above, where the escaping character needs to itself be excaped, etc.
** If the language has a way of getting the "source code representation", it usually handles the escaping of characters, so this is not a problem.
** If the language has a way of getting the "source code representation", it usually handles the escaping of characters, so this is not a problem.
** Some languages allow you to have a string literal that spans multiple lines, which embeds the newlines into the string without escaping.
** Write the entire program on one line, for free-form languages (as you can see for some of the solutions here, they run off the edge of the screen), thus removing the need for newlines. However, this may be unacceptable as some languages require a newline at the end of the file; and otherwise it is still generally good style to have a newline at the end of a file. (The task is not clear on whether a newline is required at the end of the file.) Some languages have a print statement that appends a newline; which solves the newline-at-the-end issue; but others do not.
** Write the entire program on one line, for free-form languages (as you can see for some of the solutions here, they run off the edge of the screen), thus removing the need for newlines. However, this may be unacceptable as some languages require a newline at the end of the file; and otherwise it is still generally good style to have a newline at the end of a file. (The task is not clear on whether a newline is required at the end of the file.) Some languages have a print statement that appends a newline; which solves the newline-at-the-end issue; but others do not.


Line 166: Line 167:
=={{header|PHP}}==
=={{header|PHP}}==
{{trans|C}}
{{trans|C}}
<lang php><?php $p = '<?php $p = %c%s%c; printf($p,39,$p,39); ?>'; printf($p,39,$p,39); ?></lang>
<lang php><?php $p = '<?php $p = %c%s%c; printf($p,39,$p,39); ?>
'; printf($p,39,$p,39); ?>
</lang>

Note the terminating newline.


=={{header|Python}}==
=={{header|Python}}==