Jump to content

PHP Error Skipping Comment Lines


benphp
Go to solution Solved by benphp,

Recommended Posts

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.

Link to comment
Share on other sites

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 by requinix
Link to comment
Share on other sites

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] => ?>
)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.