|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2011-03-18 12:04 UTC] gingko at gingko dot homeip dot net
Description: ------------ A parsing error occurs if a pattern looking like a closing ASP tag appears inside a line comment (beginning by '//'), in a PHP engine having 'asp_tags = On' in the 'php.ini' file. If I remove the "//" comment, I have a big "Line 2" visible, and there is no bug. If I use a "/* */" style comment instead, there is no bug. If I put quotes around "140%" in the "size" attribute, there is no bug. If I set the "asp_tags" options to "Off", or if I remove it, there is no bug. Removing the 'if' condition around the comment results in another kind of problem (no error, but part of HTML code visible). I found this because I was trying to install the latest version of OCS Inventory (http://www.ocsinventory-ng.org/), and I didn't understand why I got a white page and a PHP parse error after the first step of installation: I have 'asp_tags = On' in 'php.ini', and there is effectively a commented out '%>' pattern in their code. Looks like a little to Bug #4879 (more than 10 years old). Test script: --------------- <html> <head><title>Asp tag bug</title></head> <body> Line 1<br> <?php if (true) { //echo "<font size=140%>Line 2</font><br>"; } ?> Line 3<br> </body> </html> Expected result: ---------------- Two text lines in browsers's Window : "Line 1" "Line 3" Actual result: -------------- A white page, and the following error in Apache log : PHP Parse error: syntax error, unexpected $end in /var/www/[...]/asp_tag_bug.php on line 13 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Dec 18 13:00:01 2025 UTC |
> Ok, so why ONLY in comments? This also happens outside a comment. | <?php | if (true) { | echo "foo"; | %> | } | ?> Of course, in your case: | echo "<font size=140%>Line 2</font><br>"; "%>" is inside a string and not parsed. > Why only in LINE comments? Because that's how the manual is describing comments: | The "one-line" comment styles only comment to the end of the line | or the current block of PHP code, whichever comes first. (And a block is ending at "?>" or "%>".) vs.: | 'C' style comments end at the first */ encountered. > Shouldn't the "?>" and "%>" tags be only able to close > the corresponding "<?php"/"<?" and "<%" tags? Maybe a idea for a feature request. Conclusion: The manual is clear how PHP is working in this situation. So it's the fault of OCS Inventory (not thinking about a PHP installation with enables ASP tags)