|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2010-11-12 12:08 UTC] jost dot boekemeier at googlemail dot com
Description: ------------ PHP Parser doesn't handle comments as such <?php echo 1+2; // $msg_text = '?>RCP_11/11/10_12:31:52_070%_E009.56.35,7_N53.32.39,6_003KM/H_278DEG_0M_2_4_0_1,6_00_0'; echo 1+2; should print 33, and not print the script unevaluated. Test script: --------------- <?php echo 1+2; // $msg_text = '?>RCP_11/11/10_12:31:52_070%_E009.56.35,7_N53.32.39,6_003KM/H_278DEG_0M_2_4_0_1,6_00_0'; echo 1+2; Expected result: ---------------- 33 Actual result: -------------- 3RCP_11/11/10_12:31:52_070%_E009.56.35,7_N53.32.39,6_003KM/H_278DEG_0M_2_4_0_1,6_00_0'; echo 1+2; PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Dec 02 01:00:01 2025 UTC |
@jost dot boekemeier: I'll preface this comment with "I'm just a regular PHP user, not a PHP org member". Changing the // behavior would break the usage in in-line php, shown on the 2nd example on the doc page. Something like the following would no longer work... <p>This is a paragraph about <?php echo $subject; // important comment here ?>.</p> Looks ugly here, but with any IDE, the color-coding makes it all pretty intelligible. The doc page is pretty clear about this comment usage. The workaround to comment out any entire block containing any "?>" symbol would be to use the /* */ symbols instead. Of course this goes against convenience and habit, and as other users have noted, this breaks lines with */ appearing anywhere (ie. regex strings, nested comments, etc). But fixing -those- problems would break things elsewhere, like in this example of sourcecode documentation... function do_something(/* integer */ $some_int, /* string */ $some_str) {/* do something */} This report seems more like a feature request. I'd vote for something like skipping the in-comment PHP mode escape if the // symbol doesn't appear on a same line as any opening PHP tag. Though I'm sure devs can think of a better solution.