benphp Posted December 11, 2014 Share Posted December 11, 2014 This is new. For some reason, the PHP errors are not counting my //commented lines. Example: <?php //my comment : ?> Parse error: syntax error, unexpected ':' in D:\www\myscript.php on line 2 The error is on line 3. If I add more comments, the error is the same: <?php //my comment //my comment //my comment //my comment //my comment : ?> Parse error: syntax error, unexpected ':' in D:\www\myscript.php on line 2 Where is this setting? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/293016-php-error-skipping-comment-lines/ Share on other sites More sharing options...
requinix Posted December 11, 2014 Share Posted December 11, 2014 (edited) And if there's a space in front of the comment? Or a lone semicolon? [edit] And while I'm here, how are these files being executed? And what do you get if you do <?php //my comment //my comment //my comment //my comment //my comment echo "<pre>\n"; print_r(file(__FILE__)); echo "\n</pre>\n"; ?> Edited December 11, 2014 by requinix Quote Link to comment https://forums.phpfreaks.com/topic/293016-php-error-skipping-comment-lines/#findComment-1499240 Share on other sites More sharing options...
kicken Posted December 11, 2014 Share Posted December 11, 2014 You might have some kind of opcode cache running that is stripping comments. Not sure if that would affect the line numbers in the errors or not. Quote Link to comment https://forums.phpfreaks.com/topic/293016-php-error-skipping-comment-lines/#findComment-1499261 Share on other sites More sharing options...
benphp Posted December 11, 2014 Author Share Posted December 11, 2014 And if there's a space in front of the comment? Or a lone semicolon? [edit] And while I'm here, how are these files being executed? And what do you get if you do <?php //my comment //my comment //my comment //my comment //my comment echo "<pre>\n"; print_r(file(__FILE__)); echo "\n</pre>\n"; ?> Results: Array ( [0] => //my comment [2] => //my comment [3] => //my comment [4] => //my comment [5] => //my comment [6] => echo "\n"; print_r(file(__FILE__)); echo "\n\n"; [7] => ?> ) Quote Link to comment https://forums.phpfreaks.com/topic/293016-php-error-skipping-comment-lines/#findComment-1499340 Share on other sites More sharing options...
Solution benphp Posted December 11, 2014 Author Solution Share Posted December 11, 2014 I found the trouble. I'm using Notepad++, and I replaced all carriage returns with new line (replaced \r with \n). I'm not sure how the \r got in there. Quote Link to comment https://forums.phpfreaks.com/topic/293016-php-error-skipping-comment-lines/#findComment-1499345 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.