php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #16112 unverbose parse error
Submitted: 2002-03-15 23:28 UTC Modified: 2002-03-17 07:24 UTC
From: lowman at uiuc dot edu Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 4.1.2 OS: Linux
Private report: No CVE-ID: None
 [2002-03-15 23:28 UTC] lowman at uiuc dot edu
a nicer parse error would be usefull for the error when you comment a line that invokes <?php tags

// header("dfjdlkjfdlkjfld <?= $BLAH ?> )";

I know this isn't valid code because I'm already in <?php tags but invoking <?= in a commented php line results in a parse error that points to the line after the last level.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-03-16 06:24 UTC] derick@php.net
The bug system is not the appropriate forum for asking support
questions. For a list of a range of more appropriate places to ask
for help using PHP, please visit http://www.php.net/support.php
 [2002-03-17 06:57 UTC] lowman at uiuc dot edu
Here is code which demonstrates this flaw.

<html><head></head><body>
testing<br>
<?
$i =10;
if ($i==10) {
        print ("haha i==$i!");
        // commented line <?= $blah ?> 
        # commented line <?= $blah ?>
}
?>
</body>
</html>

My guess is PHP hits the closing ?> in the commented line and can't tell the difference.  This results in a missing brace issue which then causes the compiler giving the following very non descript error message:

Parse error: parse error in /var/www/blah.php on line 19

Of course there is no line 19 which leads me to believe it is simply a missing brace.  Checking all the braces doesn't do any good though because they all are fine.  The problem is that the closing ?> of course messes everything up.  I spent about 30 minutes trying to figure out what I had done before I realized my error.  I don't know if there is an easy way to add a check for this kind of thing but clearly if a programmer is putting ?> in comments something is wrong and maybe the interpreter should give another error for that.
 [2002-03-17 07:24 UTC] sander@php.net
Not a bug. RTM.

Parse errors have been improved in 4.2.0 and later.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue May 07 22:01:30 2024 UTC