Edit report at http://bugs.php.net/bug.php?id=40832&edit=1
ID: 40832 User updated by: derp at example dot com Reported by: derp at example dot com Summary: Behavior of PI end in single-line comment Status: Bogus Type: Feature/Change Request Package: *General Issues Operating System: Linux 2.4.26-gentoo-r7 PHP Version: 5.2.1 Block user comment: N Private report: N New Comment: re. [2010-12-22 12:21 UTC] [email protected]: Haha, I had forgotten that I'd ever used PHP, let alone filed any bugs. I suppose it's great that you still care, but you've misunderstood: Consider #! /usr/bin/php <?php "abc ?>"; ?> I am output! the output is I am output! but, if the code above is changed to #! /usr/bin/php <?php //"abc ?>"; ?> I am output! the output becomes: "; ?> I am output! Now do you see what I was talking about? The two characters ?> that were formerly part of a string literal, and therefore not recognized as a processing instruction end, suddenly start behaving as a PI-end when the string literal has been commented out. Your example has nothing to do with my suggestion (if you read carefully). Previous Comments: ------------------------------------------------------------------------ [2010-12-22 13:21:11] [email protected] The behavior is needed to allow using single line comments while embedding PHP in HTML like in <h1><?php echio $title; // comment ?></h1> Your compromise won't work as it break valid code like <?php if ($cond) { ?><h1>TRUE</h1><?php } ?> ------------------------------------------------------------------------ [2007-03-16 02:15:17] derp at example dot com Description: ------------ When a processing instruction end (PIE), i.e., "?>", is encountered in a single-line comment, the PHP parser should handle it more intelligently, thus: If the PIE would, when outside single-line comment context (SLCC), not mark the end of the current PHP code block (e.g., if it occurred inside a string literal), it should not, when inside SLCC, mark the end of the code block. --- The above represents a compromise suggestion. I feel the semantics of comments ought to be the same as those in, e.g., C, Perl; i.e., comment text should be naively stripped from the input stream seen by the parser. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=40832&edit=1
